Message313196
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()) |
|
Date |
User |
Action |
Args |
2018-03-04 00:16:44 | zmedico | set | recipients:
+ zmedico, pitrou, vstinner, christian.heimes, neologix, yselivanov, Adam.Bishop, martius, Christian H |
2018-03-04 00:16:44 | zmedico | set | messageid: <1520122604.28.0.467229070634.issue21998@psf.upfronthosting.co.za> |
2018-03-04 00:16:44 | zmedico | link | issue21998 messages |
2018-03-04 00:16:44 | zmedico | create | |
|