Closed mikenerone closed 5 months ago
This is because a function wrapped in aio_as_trio
runs in a different task from Trio's perspective (the task that's managing the asyncio loop), but tricycle was assuming that TaskStatus.started() would always run from within the new task. I uploaded oremanj/tricycle#27 which removes that assumption and fixes this example.
python
3.12.1 +trio
0.24.0 +trio-asyncio
0.13.0 +tricycle
0.4.0When used with
tricycle.BackgroundObject
, parent scope cancellations leak through prematurely totrio-asyncio
-managed asyncio tasks. I personally see this as atrio-asyncio
bug, because in principal its adapter should transparently handle any differences so thattricycle.BackgroundObject
isn't affected, but since you're the maintainer of both (at least it seems so), your opinion on that matters more than mine. :)This repro script illustrates the problem in detail:
Incidentally, you may recall that we recently saw a similar behavior with asyncio async generators in the same context. I thought I'd mention it because it could point toward a common path where a holistic fix might be possible.