A schedule fires dispatch() when the workflow declares one - #266
Merged
Conversation
A subject-backed workflow can't be scheduled: the cron fires run() with no subject, and a run about something needs one. Apps worked around it with a shim workflow whose whole body was Real.dispatch(). Now a schedule fires dispatch() when the class declares one — the policy resolves the subject and starts the real run. The tick runs no workflow of its own kind (no Run row); dispatch() runs at the scheduled workflow's body level with a session, because DBOS only allows the child-start inside start() from a workflow body. A scheduled dispatch is nullary, enforced at class definition.
czpython
force-pushed
the
commonzenpython/eng-854-schedule-dispatch
branch
from
August 17, 2026 03:03
b539994 to
8a29d0f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A subject-backed workflow can't be scheduled: the cron fires
run()with no subject, and a run about something needs one. Apps worked around it with a shim workflow whose whole body wasReal.dispatch().Now a schedule fires
dispatch()when the class declares one — the policy resolves the subject and starts the real run. The tick runs no workflow of its own kind (no Run row for the tick);dispatch()runs at the scheduled workflow's body level with a session, because DBOS only allows the child-start insidestart()from a workflow body — a step is forbidden it (dbos/_context.pyassertsis_workflow()on child-start). A failed dispatch fails the.scheduledworkflow; the next tick fires fresh.A scheduled
dispatch()fires with no arguments, so declaring one with a required parameter is a class-definition error. Detection isgetattr, so a mixin-provideddispatch()schedules the same as a declared one.The author guide's schedule section now shows the subject-backed shape instead of the shim pattern. The test drives the registered scheduled entry end to end: the tick reaches
dispatch(), whosestart()enqueues the real run about its subject.ENG-854