python-trio / trio-asyncio

a re-implementation of the asyncio mainloop on top of Trio
Other
188 stars 37 forks source link

"You cannot replace an event loop": multiple parallel / nested loops #9

Closed smurfix closed 6 years ago

smurfix commented 6 years ago

Multiple loops per Trio run requires contextvars support. That library is new in Python 3.7. There's no backport to 3.6 or 3.5 yet.

njsmith commented 6 years ago

You could use trio.TaskLocal for now

smurfix commented 6 years ago

Actually, I already do. The problem is that for now I need to switch that to a RunLocal, because otherwise subtasks won't see the global event loop.

njsmith commented 6 years ago

Wait, why is there a global event loop? :-)

smurfix commented 6 years ago

Resolved in f865772 by switching back to a TaskLocal, and monkey-patching asyncio.