Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Keep async event loop alive between cells #11829
When it comes to Trio, however, the current integration is pretty limited, because Trio has a notion of structured concurrency, which means that all concurrent tasks must belong to a specific parent (called a "nursery" in Trio parlance). Therefore, if an object needs to run any tasks (e.g. a connection object that needs a background task to read incoming network data), that object's lifetime is bound to a nursery, and a nursery's lifetime is bound to the block of a context manager. The effect is that any object that needs to spawn a long-lived Trio task can only be used within a single cell.
Here's an example:
If I execute the second cell here, it will hang for a long time. Even though the
I couldn't find any open issues tracking this idea to keep an event loop open between cells, so I'm opening this issue. I'm not sure how this would work in general, but for Trio specifically we probably want to call
I can contribute some time to helping out with this. I poked around some of the PRs and source code, but I'm not very familiar with IPython's internals, so I figure the best place to start is to brainstorm with those of you who understand the issues better than me.
Thanks for opening this issue, and for the kind words !
There are actually two sides of this issue:
I personally don't have enough time to goo deep the rabbit hole on these, but will do my best to help anyone with the motivation to do so.