diff -r c26e6beb2e35 Lib/asyncio/unix_events.py --- a/Lib/asyncio/unix_events.py Sat Jul 26 19:53:38 2014 +0300 +++ b/Lib/asyncio/unix_events.py Sat Jul 26 13:55:14 2014 -0400 @@ -9,6 +9,7 @@ import subprocess import sys import threading +from multiprocessing import current_process from . import base_events @@ -45,6 +46,7 @@ def __init__(self, selector=None): super().__init__(selector) self._signal_handlers = {} + self._pid = current_process().pid def _socketpair(self): return socket.socketpair() @@ -886,6 +888,15 @@ isinstance(threading.current_thread(), threading._MainThread): self._watcher.attach_loop(loop) + def get_event_loop(self): + # Get a new loop object if we're in a mp child process. + if (self._local._loop is not None and + self._local._loop._pid != current_process().pid): + self.set_event_loop(self.new_event_loop()) + return self._local._loop + else: + return super().get_event_loop() + def get_child_watcher(self): """Get the watcher for child processes.