From 448319dd447f0b7e21952db226b3cb2acadb4773 Mon Sep 17 00:00:00 2001 From: Bar Hofesh Date: Tue, 8 Aug 2023 13:56:15 +0300 Subject: [PATCH] Don't wait forever --- src/sec_tester/repeater.cr | 1 + src/sec_tester/scan.cr | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sec_tester/repeater.cr b/src/sec_tester/repeater.cr index 8653115..f99db26 100644 --- a/src/sec_tester/repeater.cr +++ b/src/sec_tester/repeater.cr @@ -48,6 +48,7 @@ module SecTester # handle undeployed events @socket.on("undeployed") do |_| @id = "" + @socket.off("undeployed") end Log.debug { "Repeater started" } diff --git a/src/sec_tester/scan.cr b/src/sec_tester/scan.cr index 5fcd4b3..498faf6 100644 --- a/src/sec_tester/scan.cr +++ b/src/sec_tester/scan.cr @@ -23,9 +23,13 @@ module SecTester spawn do @repeater.run end - while @repeater.id.empty? + # Wait for repeater to get ID + # Don't wait forever, if repeater is not running, we will get an error + # after 30 seconds + + 30.times do + break unless @repeater.id.empty? sleep 1.second - Fiber.yield Log.debug { "Waiting for repeater to get ID" } end end