-
Notifications
You must be signed in to change notification settings - Fork 6
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
refactor: safely store and close tasks #253
base: master
Are you sure you want to change the base?
Conversation
for check, future in self._global_wait_for_handlers: | ||
logger.debug("Dispatching to a global wait_for handler") | ||
create_task(self._run_global_wait_for_handler(check, future, event_name, *args)) | ||
async with create_task_group() as tg: |
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.
Wont this block until all callbacks have finished running? Because if so, that is going to cause issues.
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.
When the task encounters an
await
statement that requires the task to sleep until something happens, the event loop is then free to work on another task.
AnyIO Docs
It looks like it is blocking. I'm not sure what else to do though.
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.
Could a per-dispatcher task group be created?
This also waits for error handlers. Conflicts with #253 is to be expected, sorry!
This PR attempts to safely store then close any loose tasks in the code. AnyIO's task groups are used to safely handle tasks all being created to run coroutines (like the dispatcher and shard manager). Closes #190.