@@ -755,6 +755,8 @@ async def raise_on_shutdown():
755755 # Initiate core worker shutdown
756756 self ._bridge_worker .initiate_shutdown ()
757757
758+ logger .info ("Bridge shut down" )
759+
758760 # If any worker task had an exception, replace that task with a queue drain
759761 for worker , task in tasks .items ():
760762 if worker and task .done () and task .exception ():
@@ -768,12 +770,15 @@ async def raise_on_shutdown():
768770
769771 # Wait for all tasks to complete (i.e. for poller loops to stop)
770772 await asyncio .wait (tasks .values ())
773+ logger .info ("tasks waited" )
774+
771775 # Sometimes both workers throw an exception and since we only take the
772776 # first, Python may complain with "Task exception was never retrieved"
773777 # if we don't get the others. Therefore we call cancel on each task
774778 # which suppresses this.
775779 for task in tasks .values ():
776780 task .cancel ()
781+ logger .info ("tasks cancelled" )
777782
778783 # Let all activity / nexus operations completions finish. We cannot guarantee that
779784 # because poll shutdown completed (which means activities/operations completed)
@@ -782,6 +787,7 @@ async def raise_on_shutdown():
782787 await self ._activity_worker .wait_all_completed ()
783788 if self ._nexus_worker :
784789 await self ._nexus_worker .wait_all_completed ()
790+ logger .info ("Waited for workers" )
785791
786792 # Do final shutdown
787793 try :
@@ -790,6 +796,7 @@ async def raise_on_shutdown():
790796 # Ignore errors here that can arise in some tests where the bridge
791797 # worker still has a reference
792798 pass
799+ logger .info ("Set shutdown complete" )
793800
794801 # Mark as shutdown complete and re-raise exception if present
795802 self ._shutdown_complete_event .set ()
@@ -847,6 +854,8 @@ async def __aexit__(self, exc_type: Optional[Type[BaseException]], *args) -> Non
847854 if not self ._async_context_run_task :
848855 raise RuntimeError ("Never started" )
849856 await self .shutdown ()
857+ logger .info ("Shutdown complete" )
858+
850859 # Cancel our run task
851860 self ._async_context_run_task .cancel ()
852861 # Only re-raise our exception if present and exc_type is cancel
0 commit comments