René's URL Explorer Experiment


Title: fix(worker): close orchestrator generators when a dispatch ends by tamirdresher · Pull Request #300 · microsoft/durabletask-python · GitHub

Open Graph Title: fix(worker): close orchestrator generators when a dispatch ends by tamirdresher · Pull Request #300 · microsoft/durabletask-python

X Title: fix(worker): close orchestrator generators when a dispatch ends by tamirdresher · Pull Request #300 · microsoft/durabletask-python

Description: Fixes #299 Problem The executor creates a fresh orchestrator generator for each history replay. When a dispatch ends while that generator is waiting for durable work, the executor currently returns without explicitly closing it. For async bridges, this can retain tasks, event loops, and orchestration contexts indefinitely. An AnyIO cancel scope can keep the suspended task reachable through its task-state registry, so garbage collection alone does not release it. A standalone native-executor reproducer (in the linked issue) confirms the leak without Pydantic AI, a live scheduler, or real waits. Fix Close the generator in an executor finally after the dispatch finishes, including failure and version-rejection paths. Do not close between history events. Build the response before closing the generator. Closing runs the orchestrator's own finally blocks; changes made during that cleanup must not change the actions or custom status returned to the scheduler. Log ordinary cleanup failures with the instance ID, orchestration name, and traceback, without replacing the dispatch result or masking abandonment. Closing an exhausted generator remains harmless. Activity and entity executors do not own suspended orchestrator generators and need no change. The Azure Managed worker inherits this fix. TipThe diff in worker.py is mostly re-indentation from wrapping the existing body in an outer try/finally. Review with whitespace changes hidden to see the ~15 real lines. Validation Beyond the unit tests, the change was exercised end-to-end through the repository's existing integration suites: against the Durable Task Scheduler emulator (nox -s azuremanaged_tests) and against real Azure Functions hosts started with Core Tools and backed by Azurite (nox -s functions_e2e). No regressions in either. Suite Result Core unit + integration tests with Azurite (nox -s tests) 1,275 passed; 1 optional provider-import test skipped in the core-only environment and passed separately with the provider installed Durable Task Scheduler emulator, incl. the six DTS + Azurite large-payload cases (nox -s azuremanaged_tests-3.12) 90 passed, 0 skipped DTS entity-failure integration tests (unmarked, run on a separate emulator) 5 passed Azure Functions hosts, Core Tools 4.13.0 + Azurite, Python 3.13 (nox -s functions_e2e) 84 passed; 6 pre-existing skips for timers/delayed signals affected by Azure/Azurite#2343 Azure Managed service-free unit tests 187 passed Strict Pyright (repo config) and flake8 passed New tests: 19 regression cases covering suspension, completion, failure, continue-as-new, termination, replay across old/new events, version rejection, repeated closure, and failing cleanup. Tests also check that cleanup does not change the response. The AnyIO/asyncio regression runs directly and in a thread pool. It verifies that cleanup finishes before return and that tasks, loops, generators, and contexts are released after collection. AnyIO is added as a test-only dependency. Release coordination Added a core Unreleased changelog entry. No package versions or dependency minimums are changed. The Pydantic AI integration (pydantic/pydantic-ai#4764) depends on a release containing this fix. It is also relevant to the async/await work in #293 and #294.

Open Graph Description: Fixes #299 Problem The executor creates a fresh orchestrator generator for each history replay. When a dispatch ends while that generator is waiting for durable work, the executor currently returns...

X Description: Fixes #299 Problem The executor creates a fresh orchestrator generator for each history replay. When a dispatch ends while that generator is waiting for durable work, the executor currently returns...

Opengraph URL: https://github.com/microsoft/durabletask-python/pull/300

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,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-controllerpull_requests
route-actionfiles
fetch-noncev2:1ddbf72d-bed2-322f-f6cb-18c77ed95feb
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA564:1F2299:CAB6FD:11BACA9:6AFE2F10
html-safe-nonce8e3feea96809f811487e103437ba8ecd1c00218305fe4a383a41d08adfa1b657
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTY0OjFGMjI5OTpDQUI2RkQ6MTFCQUNBOTo2QUZFMkYxMCIsInZpc2l0b3JfaWQiOiI2NDYyMTIxMjkwNDIwMzM0MzUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacad3acdbc5e13283afc40a10bffe01cd738bb8fa6a14ce8717ea9a22f3359092a
hovercard-subject-tagpull_request:4934807970
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/microsoft/durabletask-python/pull/300/files
twitter:imagehttps://avatars.githubusercontent.com/u/342800?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/342800?s=400&v=4
og:image:altFixes #299 Problem The executor creates a fresh orchestrator generator for each history replay. When a dispatch ends while that generator is waiting for durable work, the executor currently returns...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noned70e31220a67f6376c108d2416fa8e7df854c1065b1672ab7a88ab6dc3a809e2
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/microsoft/durabletask-python git https://github.com/microsoft/durabletask-python.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id627664515
octolytics-dimension-repository_nwomicrosoft/durabletask-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id627664515
octolytics-dimension-repository_network_root_nwomicrosoft/durabletask-python
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseccb88d9c92abe69245b429398c8a57ae87070c7c
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/durabletask-python/pull/300/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdurabletask-python%2Fpull%2F300%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fdurabletask-python%2Fpull%2F300%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=microsoft%2Fdurabletask-python
Reloadhttps://github.com/microsoft/durabletask-python/pull/300/files
Reloadhttps://github.com/microsoft/durabletask-python/pull/300/files
Reloadhttps://github.com/microsoft/durabletask-python/pull/300/files
microsofthttps://github.com/microsoft
durabletask-pythonhttps://github.com/microsoft/durabletask-python
Codehttps://github.com/microsoft/durabletask-python
Issues15 (15)https://github.com/microsoft/durabletask-python/issues
Pull requests12 (12)https://github.com/microsoft/durabletask-python/pulls
Actionshttps://github.com/microsoft/durabletask-python/actions
Projectshttps://github.com/microsoft/durabletask-python/projects
Security and qualityhttps://github.com/microsoft/durabletask-python/security
Insightshttps://github.com/microsoft/durabletask-python/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fmicrosoft%2Fdurabletask-python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmicrosoft%2Fdurabletask-python%2Fissues%2Fnew%2Fchoose
Tamir Dresher (tamirdresher)https://github.com/tamirdresher
mainhttps://github.com/microsoft/durabletask-python/tree/main
tamirdresher-microsoft-generator-dispatch-cleanuphttps://github.com/microsoft/durabletask-python/tree/tamirdresher-microsoft-generator-dispatch-cleanup
Conversation 6 https://github.com/microsoft/durabletask-python/pull/300
Commits 2 https://github.com/microsoft/durabletask-python/pull/300/commits
Checks 27 https://github.com/microsoft/durabletask-python/pull/300/checks
Files changed https://github.com/microsoft/durabletask-python/pull/300/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/300/files
fix(worker): close orchestrator generators when a dispatch ends https://github.com/microsoft/durabletask-python/pull/300/files#top
Show all changes 2 commits https://github.com/microsoft/durabletask-python/pull/300/files
6942443 fix(worker): close suspended orchestrator generators when a dispatch … tamirdresher Oct 20, 2026 https://github.com/microsoft/durabletask-python/pull/300/commits/6942443d23a60f9717ce8b124c47fee270483980
2f85f4c docs(changelog): note generator cleanup fix in azuremanaged and funct… tamirdresher Oct 20, 2026 https://github.com/microsoft/durabletask-python/pull/300/commits/2f85f4c535a7c723519c91a7c0431b446e99a672
Clear filters https://github.com/microsoft/durabletask-python/pull/300/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/300/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/300/files
CHANGELOG.md https://github.com/microsoft/durabletask-python/pull/300/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
CHANGELOG.md https://github.com/microsoft/durabletask-python/pull/300/files#diff-5238e244f2c6b5bd4ede65c19a2cd928c40ff1a5c28bf1979651e8fe1db1a6d2
CHANGELOG.md https://github.com/microsoft/durabletask-python/pull/300/files#diff-1d1ece375471f083a849ea1b601985661b8bd8e7017fdb7fd5d10e02c4ca69f6
worker.py https://github.com/microsoft/durabletask-python/pull/300/files#diff-821cca3b6d2d4c27b83bc2ea2c1dfbce058c46419967498ae26dc12693418899
requirements.txt https://github.com/microsoft/durabletask-python/pull/300/files#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552
test_orchestration_generator_cleanup.py https://github.com/microsoft/durabletask-python/pull/300/files#diff-48ceae17758794c0f6c90139050b158a8e02d04d9fa521b5fbe379d6d701f355
CHANGELOG.mdhttps://github.com/microsoft/durabletask-python/pull/300/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
View file https://github.com/microsoft/durabletask-python/blob/2f85f4c535a7c723519c91a7c0431b446e99a672/CHANGELOG.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/300/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/300/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
andystapleshttps://github.com/andystaples
Oct 20, 2026https://github.com/microsoft/durabletask-python/pull/300/files#r4328008688
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/300/files
https://github.com/microsoft/durabletask-python/pull/300/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
azure-functions-durable/CHANGELOG.mdhttps://github.com/microsoft/durabletask-python/pull/300/files#diff-5238e244f2c6b5bd4ede65c19a2cd928c40ff1a5c28bf1979651e8fe1db1a6d2
View file https://github.com/microsoft/durabletask-python/blob/2f85f4c535a7c723519c91a7c0431b446e99a672/azure-functions-durable/CHANGELOG.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/300/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/300/files#diff-5238e244f2c6b5bd4ede65c19a2cd928c40ff1a5c28bf1979651e8fe1db1a6d2
https://github.com/microsoft/durabletask-python/pull/300/files#diff-5238e244f2c6b5bd4ede65c19a2cd928c40ff1a5c28bf1979651e8fe1db1a6d2
durabletask-azuremanaged/CHANGELOG.mdhttps://github.com/microsoft/durabletask-python/pull/300/files#diff-1d1ece375471f083a849ea1b601985661b8bd8e7017fdb7fd5d10e02c4ca69f6
View file https://github.com/microsoft/durabletask-python/blob/2f85f4c535a7c723519c91a7c0431b446e99a672/durabletask-azuremanaged/CHANGELOG.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/300/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/300/files#diff-1d1ece375471f083a849ea1b601985661b8bd8e7017fdb7fd5d10e02c4ca69f6
https://github.com/microsoft/durabletask-python/pull/300/files#diff-1d1ece375471f083a849ea1b601985661b8bd8e7017fdb7fd5d10e02c4ca69f6
durabletask/worker.pyhttps://github.com/microsoft/durabletask-python/pull/300/files#diff-821cca3b6d2d4c27b83bc2ea2c1dfbce058c46419967498ae26dc12693418899
View file https://github.com/microsoft/durabletask-python/blob/2f85f4c535a7c723519c91a7c0431b446e99a672/durabletask/worker.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/300/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/300/files#diff-821cca3b6d2d4c27b83bc2ea2c1dfbce058c46419967498ae26dc12693418899
andystapleshttps://github.com/andystaples
Oct 20, 2026https://github.com/microsoft/durabletask-python/pull/300/files#r4328008685
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/300/files
andystapleshttps://github.com/andystaples
Oct 20, 2026https://github.com/microsoft/durabletask-python/pull/300/files#r4328008675
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/300/files
https://github.com/microsoft/durabletask-python/pull/300/files#diff-821cca3b6d2d4c27b83bc2ea2c1dfbce058c46419967498ae26dc12693418899
requirements.txthttps://github.com/microsoft/durabletask-python/pull/300/files#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552
View file https://github.com/microsoft/durabletask-python/blob/2f85f4c535a7c723519c91a7c0431b446e99a672/requirements.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/durabletask-python/pull/300/{{ revealButtonHref }}
https://github.com/microsoft/durabletask-python/pull/300/files#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552
https://github.com/microsoft/durabletask-python/pull/300/files#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/300/files
Please reload this pagehttps://github.com/microsoft/durabletask-python/pull/300/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.