Repository navigation
Make cooperative callback spawn readiness configurable (default 30 s) - #390
Conversation
A cooperative activity waited a fixed 5 s for its spawned supervisor and callback to report readiness. On a busy worker several starts at once missed it, and the TimeoutError became an activity failure while the unconfirmed process kept its activity slot. Worker(activity_spawn_timeout=...) now sets the wait, default 30 s. A missed wait raises CallbackSpawnTimeout only after the supervisor joined cleanly, so the callback is proved stopped and its slot is freed. The worker then releases the claim as a retryable worker_lost failure (cause activity_spawn_readiness_timeout) with a message that names the setting. Fixes #388 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent review: BLOCKING at head 263078f The code change looks correct, and I found no broken process-ownership or stop-proof invariant. The one blocker is CI: the required What I verified
BLOCKING
Non-blocking
|
Review of #390: - Move the setting to a Worker.activity_spawn_timeout property, with a DURABLE_WORKFLOW_ACTIVITY_SPAWN_TIMEOUT default checked before run. Worker.__init__ stays unchanged, so the replay regression corpus guard no longer sees an activity setting as a replay change. - Race the start against ownership observation and worker shutdown, so a slow start no longer delays claim loss or shutdown. - Any start failure whose supervisor exits cleanly marks the callback stopped, returning its slot. Allow at least 10 s for that join after a missed readiness wait. - Say the handler had not reported started, not that no application code ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent review: PASS at head c8303f8 This is a re-review of the changes since 263078f. The earlier blocker is fixed, and I found nothing new that is unsafe. When I looked, the Python 3.10–3.15 and integration jobs at this head were still pending. What I verified
Non-blocking
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Independent review: PASS at head 60b8b99 I reviewed the change since c8303f8, which I passed earlier (previous review). It touches only text, with no code change:
That fixes non-blocking note 1. Notes 2 and 3 are still open; they are safe behavior, as described in the previous review. CI at this head has finished and every check passes:
The published-* jobs were skipped. GitHub reports the merge state as CLEAN. |



Fixes #388
Problem
SupervisedCallback.start()waited a fixed 5 s for the spawned supervisor and callback to report readiness. Each cooperative activity starts two spawn-context interpreters that import the SDK and the handler. When about eight started at once in a 2-CPU container, the wait raisedTimeoutError. The worker then reported it as an ordinary activity failure. The callback was also never marked stopped, so it kept its activity slot.Change
worker.activity_spawn_timeout(property) sets the readiness wait, default 30 s (DEFAULT_SPAWN_READINESS_TIMEOUT), orDURABLE_WORKFLOW_ACTIVITY_SPAWN_TIMEOUTfrom the environment. It must be a positive, finite number, and a malformed environment value refusesrun()before any work is claimed. It isn't a constructor argument, because any change toWorker.__init__counts as a replay change to the regression-corpus guard. Remote and prepared-local callbacks both use it. Prepared-local starts are still capped by the attempt's remaining budget.CallbackSpawnTimeout(aCallbackProcessLostsubclass) and marks the callback stopped, which frees its slot. If the supervisor doesn't exit cleanly, it stays a plainCallbackProcessLostand keeps its capacity, as before.cooperative activity callback did not report spawn readiness within 30s; the host may be overloaded. Raise Worker.activity_spawn_timeout (DURABLE_WORKFLOW_ACTIVITY_SPAWN_TIMEOUT) or lower max_concurrent_activity_tasks.CallbackSpawnTimeoutby releasing the claim through the existing cross-SDKworker_lostcontract (release_worker_lost):non_retryable=False, details causeactivity_spawn_readiness_timeout. This is a retryable worker condition, not an activity failure. The callback had not reported readiness, and it's proved stopped before the release, so two executions can't overlap.release_worker_losttakes an optionalmessage, and the lease-renewal message is unchanged.docs/reference/worker.mdhas a new "Cooperative callback start timeout" section, and there's a CHANGELOG entry.Tests
test_concurrent_cooperative_spawns_on_one_cpu_all_report_ready: pins the test process, and so its spawned children, to one CPU, starts 8 cooperative callbacks concurrently, and checks that all are ready and return typed results.test_missed_spawn_readiness_stops_the_callback_and_names_the_setting: the callback is proved stopped, its directory is removed, the handler never ran, and the message namesactivity_spawn_timeout.test_missed_spawn_readiness_releases_the_claim_as_retryable_worker_lost: the worker sends oneworker_lostfailure (non_retryable=False, causeactivity_spawn_readiness_timeout), no completion, and gets its activity slot back.test_shutdown_during_a_slow_start_aborts_without_waiting_for_readiness: the handler module stalls on import in spawned children; shutdown aborts the start within seconds and frees the slot.readiness_timeout, theactivity_spawn_timeoutproperty and the environment variable.Local: ruff and mypy are clean.
test_activity_process.py,test_cooperative_remote_worker.py,test_activity_lease_worker.py,test_activity_worker_lost.py,test_prepared_local_activity_worker.py,test_activity_checkpoint.pyandtest_telemetry.pypass. CI runs the full suites.🤖 Generated with Claude Code