[Python-ideas] Submitting a job to an asyncio event loop
C Anthony Risinger
anthony at xtfx.me
Wed Sep 30 19:35:49 CEST 2015
On Sun, Sep 27, 2015 at 11:42 AM, Guido van Rossum <guido at python.org> wrote:
> I don't think the use case involving multiple event loops in different
> threads is as clear. I am still waiting for someone who is actually trying
> to use this. It might be useful on a system where there is a system event
> loop that must be used for UI events (assuming this event loop can somehow
> be wrapped in a custom asyncio loop) and where an app might want to have a
> standard asyncio event loop for network I/O. Come to think of it, the
> ProactorEventLoop on Windows has both advantages and disadvantages, and
> some app might need to use both that and SelectorEventLoop. But this is a
> real pain (because you can't share any mutable state between event loops).
I'm not currently solving the problem this way, but I wanted to do
something like this recently for a custom Mesos framework. The framework
uses a pure-python library called "pesos" that in turn uses a pure-python
libprocess library called "compactor". compactor runs user code in a
private event loop (Mesos registration, etc). I also wanted to run my own
private loop in another thread that interacts with Redis. This loop is
expected to process some incoming updates as commands that must influence
the compactor loop (start reconciliation or some other Mesos-related thing)
and the most straightforward thing to me sounded exactly like this thread:
submitting jobs from one loop to another.
I haven't really delved into making the Redis part an async loop (it's just
threaded right now) as I'm less experienced with writing such code, so
maybe I am overlooking and/or conflating things, but seems reasonable.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas