Open jordaneremieff opened 5 years ago
So... The only place you're using asyncio
is for a single Queue instance. For trio, you'd need to swap that out with a trio Queue implementation instead.
The ASGI interface itself is agnostic - it's an async
/await
interface, rather than specifically being an asyncio
interface.
(Broader context, Trio is obviously a huge step forwards, but I'm personally lukewarm on the ecosystem split it requires vs. bringing the learnings it introduces into asyncio.)
@tomchristie Hm, interesting point about the broader context. I haven't really delved into Trio too deeply, but I've only heard good things about it and have seen various efforts to use it with ASGI.
That said, I don't have any particular interest in using it myself. I'm going to leave this as a "maybe" and won't likely do anything further, but if there are enough people that would find an ASGI Trio adapter useful I would be open to a PR.
Codewise I think it just needs a trivial change to use trio.Event()
in mangum/asgi/protocol.py
(Tho I'm not sure how best you'd expose that as a switch.) Anyways, leaving this here, for someone else to make progress on if it ends up being a requirement for someone, somewhere
Starlette is considering support for Trio here and that would make at least two frameworks that support Trio (Quart being the other) - might be worth including here.
So I admittedly don't know how much may be involved here, but my initial thoughts are that including support for ASGI applications using Trio wouldn't require too much to implement as an adapter here.