Make ASGI dispatcher asyncio-agnostic
See original GitHub issueNote: this issue breaks apart steps originally taken in #217.
The ASGI dispatcher currently relies on asyncio-specific APIs to perform various operations, which is a blocker towards supporting alternative concurrency backends.
We want to make sure all of the I/O inside ASGIDispatch
goes through the backend instead.
This will need the following, most of which can be tackled in independant PRs:
-
#257 Hard-code
self.backend = AsyncioBackend()
onASGIDispatch
to be able to iteratively defer asyncio-specific APIs to the backend. -
#257 Introduce a queue-like interface:
class BaseQueue:
async def get(self): ...
async def put(self, value: typing.Any): ...
along with a .create_queue()
method on ConcurrencyBackend
, to be used instead of/within the BodyIterator
.
(For trio we’ll probably need to add a .close()
method as well, but that can be confirmed and tackled in due time.)
- #260 Introduce a
BaseEvent
interface:
class BaseEvent:
def set(self): ...
def is_set(self): ...
async def wait(self): ...
along with a .create_event()
method on ConcurrencyBackend
to abstract asyncio.Event()
.
-
#261 Remove usage of loop.create_task() via the background manager interface.
-
Lastly, turn the hard-coded
backend
into a parameter. Make sure it is optional and we useAsyncioBackend
as a default.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
Yeah it’ll tie in. We’ll want to get this side of things all nice and clean and sorted first, then we’ll be able to take a proper look at #52 again.
Going to see if I can take a crack at dropping the
asyncio.FIRST_COMPLETED
bit of implementation, since that’d make this issue somewhat narrower in scope.