Skip to content
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

docs: avoid mentioning blocking the event loop in async implementation #115

Merged
merged 1 commit into from
Feb 25, 2024

Conversation

michalc
Copy link
Member

@michalc michalc commented Feb 25, 2024

I think I was conflating a few different things when writing about avoiding blocking the event loop as a reason for using threads in the async implementation.

The reasoning for using threads is more:

  • async_stream_zip takes async iterables
  • which means if delegating to stream_zip, it would need to call async functions like anext or __anext__ from sync functions, and wait for them to complete.
  • there is only really one choice for this that works/avoids deadlock: run_coroutine_threadsafe.
  • which means this call must be in a different thread

I think I was conflating a few different things when writing about avoiding
blocking the event loop as a reason for using threads in the async
implementation.

The reasoning for using threads is more:

- async_stream_zip takes async iterables
- which means if delegating to stream_zip, it would need to call async
  functions like anext or __anext__ from sync functions, and wait for them to
  complete.
- there is only really one choice for this that works/avoids deadlock:
  run_coroutine_threadsafe.
- which means this call must be in a different thread
@michalc michalc force-pushed the docs/avoid-blocking-event-loop-mention branch from 07be1b3 to 8e8e6f0 Compare February 25, 2024 10:43
@michalc michalc merged commit c8a4503 into main Feb 25, 2024
5 checks passed
@michalc michalc deleted the docs/avoid-blocking-event-loop-mention branch February 25, 2024 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant