@@ -351,6 +351,7 @@ def start(ctx, exclude, start_only):
351351 from sc_runner .resources import supported_vendors
352352 import concurrent .futures
353353 import threading
354+ import traceback
354355
355356 threading .current_thread ().name = "main"
356357
@@ -405,20 +406,30 @@ def start(ctx, exclude, start_only):
405406 repo .push_path (os .path .join (ctx .parent .params ["repo_path" ], "data" ), f"Start finished { repo .gha_url ()} " )
406407 logging .info ("Git push successful" )
407408
408- if exception :
409- # fail if an exception was raised in should_start
410- raise exception
411-
412- # Debug: Print all active threads and their stack traces
413- import threading
414- import traceback
415- logging .info ("Debug: Active threads after git push:" )
409+ # Print all active non-daemon threads and their stack traces
410+ non_daemon_threads = []
416411 for thread in threading .enumerate ():
412+ if thread == threading .current_thread () or thread .daemon :
413+ # skip main thread and daemon threads
414+ continue
417415 logging .info (f"Thread { thread .name } (daemon={ thread .daemon } )" )
418416 stack = traceback .format_stack (sys ._current_frames ()[thread .ident ])
419417 for line in stack :
420418 logging .info (f" { line .strip ()} " )
419+ non_daemon_threads .append (thread )
420+
421+ if non_daemon_threads :
422+ # possibly running into this: https://github.com/pulumi/pulumi/issues/16095, do a forceful exit
423+ # without waiting for non-daemon threads to finish
424+ logging .info (f"Force exiting due to { len (non_daemon_threads )} non-daemon threads still running" )
425+ if exception :
426+ os ._exit (1 )
427+ else :
428+ os ._exit (0 )
421429
430+ if exception :
431+ # fail if an exception was raised in should_start
432+ raise exception
422433
423434
424435def cleanup_task (vendor , server , data_dir , regions = [], zones = [], force = False ):
0 commit comments