diff --git a/benchmark3.py b/benchmark3.py index db8666f..4ce74a5 100644 --- a/benchmark3.py +++ b/benchmark3.py @@ -233,20 +233,23 @@ def main(): print("Running benchmark...") benchmark_results = run_benchmark(args.workers, args.timeout, args.file) - print("Waiting for inflight MQTT messages to arrive...") + # Wait for inflight messages for a little - total_successful_uploads = len([req for req in benchmark_results if req.upload_status_code == 200]) - all_arrived = False - waiting_started = time.time() - for _ in range(int(args.inflight_timeout * 1000)): - if alerts_arrived_queue.qsize() >= total_successful_uploads: - all_arrived = True - break + all_arrived = alerts_arrived_queue.qsize() >= total_successful_uploads - time.sleep(0.001) - waited_for_inflight = time.time() - waiting_started - print(f"Waited a total {waited_for_inflight} seconds") + if (not all_arrived) and (args.inflight_timeout > 0): + print("Waiting for inflight MQTT messages to arrive...") + + waiting_started = time.time() + for _ in range(int(args.inflight_timeout * 1000)): + if alerts_arrived_queue.qsize() >= total_successful_uploads: + all_arrived = True + break + + time.sleep(0.001) + waited_for_inflight = time.time() - waiting_started + print(f"Waited a total {waited_for_inflight} seconds") if not all_arrived: print("WARNING: Not all MQTT Messages arrived!")