-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
utils/asyn: Ensure the async generators inside context managers are f…
…ully consumed on a single event loop Context managers implemented using contextlib.asynccontextmanager() rely on an async generators. This async generator must be fully consumed on a single event loop, otherwise: 1. The async generator will be closed after the __enter__ run() call, as event loops close all async generators upon closing. 2. The async generator would end up being migrated from one event loop to another, which is not going to work. Sidestep both issues by ensuring that the same event loop is in use for both __enter__() and __exit__(). If necessary, _AsyncPolymorphicCM() creates and manages its own event loop to ensure this is the case.
- Loading branch information
1 parent
a1677c1
commit d071e9d
Showing
1 changed file
with
82 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters