Skip to content

Commit a232762

Browse files
committed
fixed delay issue. todo: full blown testing and merge
1 parent 16a4ece commit a232762

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

examples/nmap_task.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
from libnmap.process import NmapProcess
44
from time import sleep
55

6-
7-
nmap_proc = NmapProcess(targets="scanme.nmap.org", options="-sV")
8-
nmap_proc.run_background()
9-
while nmap_proc.is_alive():
6+
def mycallback(nmaptask):
107
nmaptask = nmap_proc.current_task
118
if nmaptask:
129
print "Task {0} ({1}): ETC: {2} DONE: {3}%".format(nmaptask.name,
1310
nmaptask.status,
1411
nmaptask.etc,
1512
nmaptask.progress)
16-
sleep(2)
1713

18-
print "rc: {0} output: {1}".format(nmap_proc.rc, nmap_proc.summary)
14+
nmap_proc = NmapProcess(targets="scanme.nmap.org",
15+
options="-sV",
16+
event_callback=mycallback)
17+
nmap_proc.run()
1918
print nmap_proc.stdout
19+
print nmap_proc.stderr

libnmap/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def ioreader_routine(proc_stdout, io_queue, data_pushed, producing):
282282
while(self.__nmap_proc.poll() is None or producing.value == 1):
283283
if self.__process_killed.is_set():
284284
break
285-
if producing.value == 1:
285+
if producing.value == 1 and qout.empty():
286286
try:
287287
data_pushed.wait()
288288
except KeyboardInterrupt:

0 commit comments

Comments
 (0)