mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Revert "bpo-22087: Fix Policy.get_event_loop() to detect fork (GH-7208)" (#7232)
This reverts commit 5d97b7bcc1
.
This commit is contained in:
parent
dec947ca26
commit
99279ad823
3 changed files with 0 additions and 42 deletions
|
@ -625,23 +625,16 @@ class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
|
|||
|
||||
class _Local(threading.local):
|
||||
_loop = None
|
||||
_pid = None
|
||||
_set_called = False
|
||||
|
||||
def __init__(self):
|
||||
self._local = self._Local()
|
||||
self._local._pid = os.getpid()
|
||||
|
||||
def get_event_loop(self):
|
||||
"""Get the event loop.
|
||||
|
||||
This may be None or an instance of EventLoop.
|
||||
"""
|
||||
if self._local._pid != os.getpid():
|
||||
# If we detect we're in a child process forked by multiprocessing,
|
||||
# we reset self._local so that we'll get a new event loop.
|
||||
self._local = self._Local()
|
||||
|
||||
if (self._local._loop is None and
|
||||
not self._local._set_called and
|
||||
isinstance(threading.current_thread(), threading._MainThread)):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue