mirror of
https://github.com/nfstream/nfstream.git
synced 2026-05-16 11:15:03 +00:00
Fix multiple runs case.
This commit is contained in:
parent
fe03480a0b
commit
4df50e4b7b
1 changed files with 17 additions and 14 deletions
|
|
@ -52,20 +52,23 @@ class NFStreamer(object):
|
|||
self._stopped = False
|
||||
|
||||
def __iter__(self):
|
||||
self._producer.start()
|
||||
tm.sleep(0.1)
|
||||
self._consumer.connect('ipc:///tmp/nfstream.pipe')
|
||||
while True:
|
||||
try:
|
||||
flow = self._consumer.recv_pyobj()
|
||||
if flow is None:
|
||||
break
|
||||
else:
|
||||
yield flow
|
||||
except KeyboardInterrupt:
|
||||
if not self._stopped:
|
||||
self._stopped = True
|
||||
self._cache.stopped = True
|
||||
try:
|
||||
self._producer.start()
|
||||
tm.sleep(0.1)
|
||||
self._consumer.connect('ipc:///tmp/nfstream.pipe')
|
||||
while True:
|
||||
try:
|
||||
flow = self._consumer.recv_pyobj()
|
||||
if flow is None:
|
||||
break
|
||||
else:
|
||||
yield flow
|
||||
except KeyboardInterrupt:
|
||||
if not self._stopped:
|
||||
self._stopped = True
|
||||
self._cache.stopped = True
|
||||
except RuntimeError:
|
||||
return None
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue