Zac Medico <zmed...@gentoo.org> added the comment:

I'm not sure about possible use cases that might conflict with this approach, 
but using a separate event loop for each pid seems very reasonable to me, as 
follows:

_default_policy = asyncio.get_event_loop_policy()
_pid_loop = {}

class MultiprocessingPolicy(asyncio.AbstractEventLoopPolicy):
        def get_event_loop(self):
                pid = os.getpid()
                loop = _pid_loop.get(pid)
                if loop is None:
                        loop = self.new_event_loop()
                        _pid_loop[pid] = loop
                return loop

        def new_event_loop(self):
                return _default_policy.new_event_loop()

asyncio.set_event_loop_policy(MultiprocessingPolicy())

----------
nosy: +zmedico

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue21998>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to