Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
@Lancetnik asked to replace the awaiting of
asyncio.Event
in favor ofasyncio.sleep
in a loop, so that the implementation would be similar to uvicorn:https://github.com/encode/uvicorn/blob/079f07a06457717b6f8c4b23bab7674d5f0568c1/uvicorn/server.py#L222-L229
The solution with
asyncio.Event
in the__init__
did not allow amateurs to use global object storage to use the library correctly, cause event instance became attached to another event loop.I proposed an option to ensure compatibility with the use of
asyncio.Event
with lazy creation, but @Lancetnik asked forasyncio.sleep
only. So I copy solution from unicorn.Fixes #1837
Type of change
Please delete options that are not relevant.
Checklist
scripts/lint.sh
shows no errors)scripts/test-cov.sh
scripts/static-analysis.sh