diff options
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/events.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py index a327ba54a32..39a01048b4c 100644 --- a/Lib/asyncio/events.py +++ b/Lib/asyncio/events.py @@ -17,6 +17,7 @@ import socket import subprocess import sys import threading +import signal from . import format_helpers @@ -665,6 +666,14 @@ class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy): def __init__(self): self._local = self._Local() + if hasattr(os, 'fork'): + def on_fork(): + # Reset the loop and wakeupfd in the forked child process. + self._local = self._Local() + signal.set_wakeup_fd(-1) + + os.register_at_fork(after_in_child=on_fork) + def get_event_loop(self): """Get the event loop for the current context. |