aboutsummaryrefslogtreecommitdiff
path: root/examples/py-flow-info/flow-info.py
diff options
context:
space:
mode:
authorlns <matzeton@googlemail.com>2022-04-17 18:56:30 +0200
committerlns <matzeton@googlemail.com>2022-04-17 18:56:30 +0200
commitc7bf94e9f128e9a76a76d355a8ce77c3cc3ca6d9 (patch)
tree19e5789c61c90c6f5fe138a9e716d53299dd4ad9 /examples/py-flow-info/flow-info.py
parenta2547321bb3d7b5e70ec8eedd02a28adb23881d4 (diff)
nDPIsrvd.(h|py): Added socket read/recv timeout.
* nDPIsrvd.h: support for O_NONBLOCK nDPIsrvd_socket Signed-off-by: lns <matzeton@googlemail.com>
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()