-
Notifications
You must be signed in to change notification settings - Fork 553
bidi - async - remove cancelling call #1357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| Attributes: | ||
| _tasks: List of tasks in group. | ||
| _tasks: Set of tasks in group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching to set to be consistent with asyncio.wait which puts done_tasks and pending_tasks into sets. This in turn helps to resolve a mypy error.
| - The context re-raises Exceptions to the caller. | ||
| - The context re-raises CancelledErrors to the caller only if the context itself was cancelled. | ||
| """ | ||
| try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have the execution rules listed above in the docstring. To repeat here:
"""Execute tasks in group.
The following execution rules are enforced:
- The context stops executing all tasks if at least one task raises an Exception or the context is cancelled.
- The context re-raises Exceptions to the caller.
- The context re-raises CancelledErrors to the caller only if the context itself was cancelled.
"""
| await asyncio.gather(*self._tasks) | ||
| pending_tasks = self._tasks | ||
| while pending_tasks: | ||
| done_tasks, pending_tasks = await asyncio.wait(pending_tasks, return_when=asyncio.FIRST_EXCEPTION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we reassign pending_tasks which led mypy to complain about set[Task] vs list[Task] and thus why I switched self._tasks to set[Task].
16f8271 to
a3b4074
Compare
Description
Removing another Python 3.11+ feature from bidi. Specifically, removing the asyncio
task.cancellingcall. This call was used in determining how to propagateasyncio.CancelledErrors in our_TaskGroupimplementation.Note, this PR is part of a larger effort to add Python 3.10 and 3.11 support to
bidi. The final PR for this work is currently in draft here.Related Issues
#1299
Documentation PR
N/A
Type of Change
Other (please describe): Compatibility update.
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run preparehatch run bidi:prepare: Relying on both existing and new unit testshatch run bidi-test:test tests_integ/bidiChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.