Closed lordi closed 5 years ago
Opening an asyncio loop is just the first step. You didn't actually switch to that asyncio context.
You can fix this by decorating your main
with @aio_as_trio
, or by calling aio_as_trio(fetch)(session, …)
. (Not both!)
However, aiohttp is a bit fiddly in that it expects to be in asyncio context for some sync operations, thus I'd definitely recommend the former method.
Ok, this works. Thank you. Maybe the docs can be improved with regard to that. It was not clear to me.
aio_as_trio
does not appear in https://trio-asyncio.readthedocs.io/en/latest/usage.html
I took the example from aiohttp README and added trio_asyncio magic:
This results in:
What causes this error? What would be a better way to call aiohttp from trio?