aboutsummaryrefslogtreecommitdiff
path: root/examples/py-flow-info/flow-info.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/py-flow-info/flow-info.py')
-rwxr-xr-xexamples/py-flow-info/flow-info.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/examples/py-flow-info/flow-info.py b/examples/py-flow-info/flow-info.py
index 0dbc5e63c..f11750351 100755
--- a/examples/py-flow-info/flow-info.py
+++ b/examples/py-flow-info/flow-info.py
@@ -426,8 +426,16 @@ if __name__ == '__main__':
nsock = nDPIsrvdSocket()
nsock.connect(address)
+ nsock.timeout(1.0)
stats = Stats(nsock)
- try:
- nsock.loop(onJsonLineRecvd, onFlowCleanup, stats)
- except KeyboardInterrupt:
- print('\n\nKeyboard Interrupt: cleaned up {} flows.'.format(len(nsock.shutdown())))
+
+ while True:
+ try:
+ nsock.loop(onJsonLineRecvd, onFlowCleanup, stats)
+ except KeyboardInterrupt:
+ print('\n\nKeyboard Interrupt: cleaned up {} flows.'.format(len(nsock.shutdown())))
+ break
+ except TimeoutError:
+ stats.updateSpinner()
+ stats.resetStatus()
+ stats.printStatus()