From 423cb1b44226d8392935a3091cceb00a3a2512c6 Mon Sep 17 00:00:00 2001 From: marcsello Date: Mon, 26 Jul 2021 16:06:31 +0200 Subject: [PATCH] Added interrupt handler to inflight wait --- benchmark2.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/benchmark2.py b/benchmark2.py index 137b01a..33774d4 100644 --- a/benchmark2.py +++ b/benchmark2.py @@ -337,10 +337,13 @@ def run_benchmark( total_successful_uploads = len([req for req in results.values() if req.upload_status_code == 200]) # Wait for inflight messages for a little - for _ in range(int(inflight_timeout)): - time.sleep(1) - if returned_queue.qsize() >= total_successful_uploads: - break + try: + for _ in range(int(inflight_timeout)): + time.sleep(1) + if returned_queue.qsize() >= total_successful_uploads: + break + except KeyboardInterrupt: + print("jovan akkor nem vĂ¡rom meg...") mqtt_client.disconnect() mqtt_client.loop_stop() # This stops further recieving MQTT messages