I think you make a good point. My solution in the meantime has been to check a multiprocessing.Qeue periodically instead (via the event loop's call_later method), since the scenario is to act on messages from a child process. I think it works quite well, and I could do away with the thread I was originally using to monitor the queue.
I guess the practical effect of your proposed solution would be about the same as using a thread to wait on the shared queue? The pipe was only relevant because I could monitor it through IOCP. Arve On Wed, Sep 24, 2014 at 6:27 PM, Guido van Rossum <[email protected]> wrote: > Maybe the following can be made to work? Use two threads, each with an > event loop. One thread uses a SelectorEventLoop, the other uses a > ProactorEventLoop. Callbacks and coroutines running in these threads > threads should communicate using call_soon_threadsafe(). (I suppose very > brief periods of locking to update or access shared variables would also be > okay, as long as no I/O is ever done while holding the lock.) > > On Wed, Sep 24, 2014 at 8:47 AM, Andrew Svetlov <[email protected]> > wrote: > >> Hi. I'm author of aiozmq. >> >> The library has very limited Windows support (Windows is a >> second-class citizen in 0MQ world btw). >> It cannot work with ProactorEventLoop and there is no way to solve the >> issue due 0MQ API limitations. >> >> Old-style ZmqEventLoop (with ZmqEventLoopPolicy) can be used as >> replacement for _WindowSelectorEventLoop with ZeroMQ socket support. >> >> Say again, the problem not in missing add_reader/add_writer but in 0MQ >> library implementation details. >> >> On Wed, Sep 24, 2014 at 5:57 PM, Guido van Rossum <[email protected]> >> wrote: >> > I don't know much about the Windows primitives used by Proactor -- the >> best >> > I can recommend is that you try to figure out how to do this by >> studying the >> > source and experimenting, and then suggest a patch. >> > >> > On Tue, Sep 23, 2014 at 11:51 PM, Arve Knudsen <[email protected]> >> > wrote: >> >> >> >> Hi guys >> >> >> >> Is there some way to work around the missing support for >> >> add_reader/add_writer in asyncio.ProactorEventLoop? Specifically, I'm >> trying >> >> to use a library (aiozmq) that detects when it's able to read from >> sockets >> >> (via add_reader) and to write to sockets (via add_writer), and I would >> like >> >> to combine it with ProactorEventLoop. >> >> >> >> Thanks, >> >> Arve >> > >> > >> > >> > >> > -- >> > --Guido van Rossum (python.org/~guido) >> >> >> >> -- >> Thanks, >> Andrew Svetlov >> > > > > -- > --Guido van Rossum (python.org/~guido) >
