@@ -385,7 +385,7 @@ def quick_start(
385385 test_suite_id = "9df7489d-92b3-49f9-95ca-512160d7896f"
386386
387387 click .echo (f"run-profile with table_group_id: { table_group_id } " )
388- message = run_profiling (table_group_id , run_date = now_date + time_delta )
388+ message = run_profiling (table_group_id , run_date = now_date + time_delta )
389389 click .echo ("\n " + message )
390390
391391 LOG .info (f"run-test-generation with table_group_id: { table_group_id } test_suite: { settings .DEFAULT_TEST_SUITE_KEY } " )
@@ -640,8 +640,6 @@ def list_ui_plugins():
640640def run_ui ():
641641 from testgen .ui .scripts import patch_streamlit
642642
643- status_code : int = - 1
644-
645643 use_ssl = os .path .isfile (settings .SSL_CERT_FILE ) and os .path .isfile (settings .SSL_KEY_FILE )
646644
647645 patch_streamlit .patch (force = True )
@@ -656,25 +654,29 @@ def cancel_all_running():
656654
657655 cancel_all_running ()
658656
659- try :
660- app_file = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "ui/app.py" )
661- status_code = subprocess .check_call (
662- [ # noqa: S607
663- "streamlit" ,
664- "run" ,
665- app_file ,
666- "--browser.gatherUsageStats=false" ,
667- "--client.showErrorDetails=none" ,
668- "--client.toolbarMode=minimal" ,
669- f"--server.sslCertFile={ settings .SSL_CERT_FILE } " if use_ssl else "" ,
670- f"--server.sslKeyFile={ settings .SSL_KEY_FILE } " if use_ssl else "" ,
671- "--" ,
672- f"{ '--debug' if settings .IS_DEBUG else '' } " ,
673- ],
674- env = {** os .environ , "TG_JOB_SOURCE" : "UI" }
675- )
676- except Exception :
677- LOG .exception (f"Testgen UI exited with status code { status_code } " )
657+ app_file = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "ui/app.py" )
658+ process = subprocess .Popen (
659+ [ # noqa: S607
660+ "streamlit" ,
661+ "run" ,
662+ app_file ,
663+ "--browser.gatherUsageStats=false" ,
664+ "--client.showErrorDetails=none" ,
665+ "--client.toolbarMode=minimal" ,
666+ f"--server.sslCertFile={ settings .SSL_CERT_FILE } " if use_ssl else "" ,
667+ f"--server.sslKeyFile={ settings .SSL_KEY_FILE } " if use_ssl else "" ,
668+ "--" ,
669+ f"{ '--debug' if settings .IS_DEBUG else '' } " ,
670+ ],
671+ env = {** os .environ , "TG_JOB_SOURCE" : "UI" }
672+ )
673+ def term_ui (signum , _ ):
674+ LOG .info (f"Sending termination signal { signum } to Testgen UI" )
675+ process .send_signal (signum )
676+ signal .signal (signal .SIGINT , term_ui )
677+ signal .signal (signal .SIGTERM , term_ui )
678+ status_code = process .wait ()
679+ LOG .log (logging .ERROR if status_code != 0 else logging .INFO , f"Testgen UI exited with status code { status_code } " )
678680
679681
680682@cli .command ("run-app" , help = "Runs TestGen's application modules" )
0 commit comments