@@ -640,18 +640,23 @@ def _install_via_dispatcher(version: str, pkg_spec: str, thread_id: int) -> dict
640640 # Shutdown daemon before exit so CI runner doesn't wait for orphaned children
641641 # (FS watcher watchdog threads, socket listeners, etc.)
642642 try :
643- from omnipkg .isolation .worker_daemon import DaemonClient
644- safe_print (" 🛑 Shutting down daemon..." )
645- DaemonClient ().shutdown ()
646- time .sleep (2 ) # give it a moment to actually die
647- safe_print (" ✅ Daemon shutdown sent" )
643+ from omnipkg .isolation .worker_daemon import cli_stop
644+ safe_print ("\n ==================================================" )
645+ safe_print ("🛑 PERFORMING ROBUST DAEMON TEARDOWN" )
646+ safe_print ("==================================================" )
647+
648+ # This does the graceful shutdown -> force kill -> orphan sweep -> file cleanup
649+ cli_stop ()
650+
651+ safe_print ("✅ Teardown complete. No orphaned processes remaining." )
648652 except Exception as e :
649- safe_print (f" ⚠️ Daemon shutdown failed: { e } " )
653+ safe_print (f" ⚠️ Robust teardown failed: { e } " )
650654
651- # Dump again after shutdown so we can see if it actually stopped cleanly
652- # or if the FS watcher / socket threads are still logging after the signal.
655+ # Now the POST-SHUTDOWN log dump will actually be accurate because the process is DEAD.
653656 dump_daemon_log ("POST-SHUTDOWN DAEMON LOG (always)" , only_on_error = False )
654657
658+ # Final exit
659+
655660 # os._exit bypasses atexit handlers and thread finalizers entirely.
656661 # sys.exit(0) goes through Python teardown which can hang if any background
657662 # thread (DaemonClient keepalive, watchdog observer, etc.) is still running.
0 commit comments