Title: [Async stack 1/6] Coroutine dispatch by andystaples · Pull Request #357 · microsoft/durabletask-python · GitHub
Open Graph Title: [Async stack 1/6] Coroutine dispatch by andystaples · Pull Request #357 · microsoft/durabletask-python
X Title: [Async stack 1/6] Coroutine dispatch by andystaples · Pull Request #357 · microsoft/durabletask-python
Description: WarningDo not merge this PR, or any other PR in the stack, on its own. The whole stack will be squash-merged once every PR in it is approved. Layer 1/6 of the async orchestrator stack, which splits the closed #293 for review. It is based on #356. Scope shared.is_async_callable classifies orchestrator callables. Each callable is checked directly first: coroutine functions are async and generator functions are synchronous, even when they carry functools.wraps metadata from a function of the other kind. Partials and callable objects resolve through func and __call__; only a callable that is neither falls back to the function it wraps. Cyclic __wrapped__ chains are reported as errors. The worker registry classifies each orchestrator once, at registration, so wrapper cycles fail when the orchestrator is registered rather than on every dispatch. Validation at the point where the worker calls the orchestrator: A sync callable that returns a coroutine is rejected, and the coroutine is closed. An async-classified callable that returns something other than a coroutine is rejected with guidance about functools.wraps. If it returned a generator, that generator is closed. Async generators are rejected. Generators that yield anything other than a Task are rejected with TypeError ("The orchestrator generator yielded a non-Task object", plus a hint to use async def). This now includes the first yield, so a bare first yield or yield [task] fails on the first dispatch. Previously a bare first yield left the instance pending indefinitely, and a non-Task first yield scheduled its work and then failed later with AttributeError. The worker runs coroutine orchestrators and resumes them during replay through a minimal deterministic DurableEventLoop (durabletask/internal/asyncio_loop.py). This loop is enough to: drive the root coroutine suspend it on durable tasks deliver completions fail when the orchestrator is blocked on work that isn't durable loop.time() is derived from the replay-safe orchestration clock (naive or timezone-aware). Loop timers, including asyncio.sleep() with a positive delay, fail with an error that points to ctx.create_timer(...) until #358 adds durable loop timers. The module docstring of asyncio_loop.py lists each private asyncio API the loop depends on and why. Task.__await__ and Task.wait() are now concrete. Inside the durable loop, awaiting suspends on the durable task. Awaiting with no running loop or under a different event loop raises RuntimeError. Adds the SyncOrchestrator, AsyncOrchestrator, and Orchestrator aliases. Generator orchestrators that yield durable tasks behave as before, and a new test replays a generator history in the form earlier releases record it. The only generator change is the first-yield check above. Teardown now always closes the orchestrator, whether it is a generator or a coroutine. Temporary differences (resolved in later layers) Context: async orchestrators receive the existing OrchestrationContext, and AsyncOrchestrator is typed against it. Layer 4/6 (#361) adds the cold AsyncOrchestrationContext, its tests, and the context API and metadata parity tests. Event loop: general asyncio composition (durable timers and asyncio.sleep with a positive delay, TaskGroup ordering) and the executor and thread guards come in layer 2/6 (#358). Teardown: the cleanup and quiesce policy and async-generator hooks come in layer 3/6 (#360). Changelog: layers 0-5 do not touch changelogs. The release entries are added only in layer 6/6 (#364).
Open Graph Description: WarningDo not merge this PR, or any other PR in the stack, on its own. The whole stack will be squash-merged once every PR in it is approved. Layer 1/6 of the async orchestrator stack, which split...
X Description: WarningDo not merge this PR, or any other PR in the stack, on its own. The whole stack will be squash-merged once every PR in it is approved. Layer 1/6 of the async orchestrator stack, which split...
Opengraph URL: https://github.com/microsoft/durabletask-python/pull/357
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:faa4bcbf-28ce-f533-3a9a-9b9f55061495 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DFF0:2C6222:49E1E:6265B:6AFE2E91 |
| html-safe-nonce | 0ba9d204240594fb03175d13b9c8ca7eb4ba8a9294a506b85824c5b8d3ad3735 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkYwOjJDNjIyMjo0OUUxRTo2MjY1Qjo2QUZFMkU5MSIsInZpc2l0b3JfaWQiOiIzMTI0NjgzNDAwNzc5MDE3ODczIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a6a43065225519b9a93ef740fd2cf5262ddd48a138e552c98edf5bf08bb6f4bb |
| hovercard-subject-tag | pull_request:5265656762 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/microsoft/durabletask-python/pull/357/files |
| twitter:image | https://avatars.githubusercontent.com/u/77818326?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/77818326?s=400&v=4 |
| og:image:alt | WarningDo not merge this PR, or any other PR in the stack, on its own. The whole stack will be squash-merged once every PR in it is approved. Layer 1/6 of the async orchestrator stack, which split... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | d70e31220a67f6376c108d2416fa8e7df854c1065b1672ab7a88ab6dc3a809e2 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/microsoft/durabletask-python git https://github.com/microsoft/durabletask-python.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 627664515 |
| octolytics-dimension-repository_nwo | microsoft/durabletask-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627664515 |
| octolytics-dimension-repository_network_root_nwo | microsoft/durabletask-python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ccb88d9c92abe69245b429398c8a57ae87070c7c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width