Skip to content

Commit 7a075ce

Browse files
committed
Work around pulumi/pulumi#16095
1 parent 7813dca commit 7a075ce

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

inspector/inspector.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

424435
def cleanup_task(vendor, server, data_dir, regions=[], zones=[], force=False):

0 commit comments

Comments
 (0)