Skip to content

Commit 2eb7184

Browse files
rkannan82claude
andcommitted
Add Python-side shutdown timing logs for diagnosis
Add print statements with timestamps at key shutdown points (initiate_shutdown, poller drain, finalize_shutdown) to correlate with TEMP_FIX poll cancellation timestamps and determine if the race is slow ShutdownWorker RPC or in-flight polls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e7340dd commit 2eb7184

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

temporalio/bridge/sdk-core

temporalio/worker/_worker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,9 @@ async def raise_on_shutdown():
837837
)
838838

839839
# Initiate core worker shutdown
840+
logger.error("SHUTDOWN-DEBUG: initiate_shutdown called")
840841
self._bridge_worker.initiate_shutdown()
842+
logger.error("SHUTDOWN-DEBUG: initiate_shutdown returned")
841843

842844
# If any worker task had an exception, replace that task with a queue drain
843845
for worker, task in tasks.items():
@@ -853,7 +855,9 @@ async def raise_on_shutdown():
853855
self._nexus_worker.notify_shutdown()
854856

855857
# Wait for all tasks to complete (i.e. for poller loops to stop)
858+
logger.error("SHUTDOWN-DEBUG: awaiting poller loops")
856859
await asyncio.wait(tasks.values())
860+
logger.error("SHUTDOWN-DEBUG: poller loops stopped")
857861
# Sometimes both workers throw an exception and since we only take the
858862
# first, Python may complain with "Task exception was never retrieved"
859863
# if we don't get the others. Therefore we call cancel on each task
@@ -871,7 +875,9 @@ async def raise_on_shutdown():
871875

872876
# Do final shutdown
873877
try:
878+
logger.error("SHUTDOWN-DEBUG: finalize_shutdown called")
874879
await self._bridge_worker.finalize_shutdown()
880+
logger.error("SHUTDOWN-DEBUG: finalize_shutdown returned")
875881
except:
876882
# Ignore errors here that can arise in some tests where the bridge
877883
# worker still has a reference

0 commit comments

Comments
 (0)