Skip to content

Commit 76c2c98

Browse files
committed
Add a sleep in the NmapProcess.__wait. This has the down side of reducing the resolutionof our polling for output from or completion of the command, but has the benefit of greatly reducing CPU utilization in libnmap. Before this change we would sit at 100% CPU in libnmap while a long running scan was in progress.
1 parent eec2258 commit 76c2c98

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

libnmap/process.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from threading import Thread
88
from xml.dom import pulldom
99
import warnings
10+
import time
1011
try:
1112
from Queue import Queue, Empty, Full
1213
except ImportError:
@@ -271,6 +272,7 @@ def __wait(self):
271272
self.__nmap_event_callback(self)
272273
self.__stdout += thread_stream
273274
self.__io_queue.task_done()
275+
time.sleep(0.01)
274276

275277
self.__nmap_rc = self.__nmap_proc.poll()
276278
if self.rc is None:

0 commit comments

Comments
 (0)