Make ConcurrencyContext exit cleanup best-effort#22619
Conversation
Co-authored-by: Alexander Streed <alex.s@prefect.io> Co-Authored-By: alex.s <ajstreed1@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-authored-by: Alexander Streed <alex.s@prefect.io> Co-Authored-By: alex.s <ajstreed1@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c49479c130
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Co-authored-by: Alexander Streed <alex.s@prefect.io> Co-Authored-By: alex.s <ajstreed1@gmail.com>
Merging this PR will not alter performance
Comparing Footnotes
|
Co-authored-by: Alexander Streed <alex.s@prefect.io> Co-Authored-By: alex.s <ajstreed1@gmail.com>
closes #22615
ConcurrencyContext.__exit__released its fallbackcleanup_lease_idsin a bare loop, so a single transient failure stranded every remaining lease (holding slots until TTL expiry) and skippedsuper().__exit__(). This PR guards each release individually, logs a warning on failure, and always runs the context teardown. The same fix is applied to the v1 context'scleanup_slotsloop, which had the identical pattern.The outer
get_client(...)block is also guarded so client construction/teardown errors don't bypasssuper().__exit__().Tests
tests/concurrency/test_context.pyandtests/concurrency/v1/test_context.pyeach get a test where the first cleanup release raises: the remaining IDs are still attempted and the context var is reset.Checklist
<link to issue>"Link to Devin session: https://app.devin.ai/sessions/b7ce20e35d99461fba5c18d77790ca3f
Requested by: @desertaxle