diff --git a/gui/app.py b/gui/app.py index 3356e44..c52a9db 100644 --- a/gui/app.py +++ b/gui/app.py @@ -268,6 +268,8 @@ def scanner_navigation_guard(): scanner_process = None +scanner_starting = False + scanner_health = "READY" scanner_stopped_at = None @@ -2374,31 +2376,44 @@ def scanner_start(): global scanner_process global scanner_health global scanner_stopped_at + global scanner_starting with scanner_lock: if ( - scanner_process is not None - and - scanner_process.poll() is None + scanner_starting + or + ( + scanner_process is not None + and + scanner_process.poll() is None + ) ): return redirect( url_for("index") ) - if get_gps_test_status()["running"]: + with gps_test_lock: - with scanner_lock: + if ( + gps_test_service is not None + and + gps_test_service.thread is not None + and + gps_test_service.thread.is_alive() + ): - scanner_output.append( - "[GUI] Scanner cannot start " - "while GPS test is running." - ) + scanner_output.append( + "[GUI] Scanner cannot start " + "while GPS test is running." + ) - return redirect( - url_for("index") - ) + return redirect( + url_for("index") + ) + + scanner_starting = True interface = request.form.get( "interface", @@ -2460,6 +2475,8 @@ def scanner_start(): with scanner_lock: + scanner_starting = False + scanner_output.append( f"[GUI] Failed to start scanner: {error}" ) @@ -2473,6 +2490,8 @@ def scanner_start(): scanner_process = process + scanner_starting = False + scanner_health = "ACTIVE" scanner_stopped_at = None