mirror of
https://github.com/python/cpython.git
synced 2025-09-18 22:50:26 +00:00
bpo-38951: Use threading.main_thread() check in asyncio (GH-17433)
https://bugs.python.org/issue38951
This commit is contained in:
parent
bb815499af
commit
99eb70a9eb
2 changed files with 3 additions and 4 deletions
|
@ -636,7 +636,7 @@ class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
|
||||||
"""
|
"""
|
||||||
if (self._local._loop is None and
|
if (self._local._loop is None and
|
||||||
not self._local._set_called and
|
not self._local._set_called and
|
||||||
isinstance(threading.current_thread(), threading._MainThread)):
|
threading.current_thread() is threading.main_thread()):
|
||||||
self.set_event_loop(self.new_event_loop())
|
self.set_event_loop(self.new_event_loop())
|
||||||
|
|
||||||
if self._local._loop is None:
|
if self._local._loop is None:
|
||||||
|
|
|
@ -1406,8 +1406,7 @@ class _UnixDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
|
||||||
with events._lock:
|
with events._lock:
|
||||||
if self._watcher is None: # pragma: no branch
|
if self._watcher is None: # pragma: no branch
|
||||||
self._watcher = ThreadedChildWatcher()
|
self._watcher = ThreadedChildWatcher()
|
||||||
if isinstance(threading.current_thread(),
|
if threading.current_thread() is threading.main_thread():
|
||||||
threading._MainThread):
|
|
||||||
self._watcher.attach_loop(self._local._loop)
|
self._watcher.attach_loop(self._local._loop)
|
||||||
|
|
||||||
def set_event_loop(self, loop):
|
def set_event_loop(self, loop):
|
||||||
|
@ -1421,7 +1420,7 @@ class _UnixDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
|
||||||
super().set_event_loop(loop)
|
super().set_event_loop(loop)
|
||||||
|
|
||||||
if (self._watcher is not None and
|
if (self._watcher is not None and
|
||||||
isinstance(threading.current_thread(), threading._MainThread)):
|
threading.current_thread() is threading.main_thread()):
|
||||||
self._watcher.attach_loop(loop)
|
self._watcher.attach_loop(loop)
|
||||||
|
|
||||||
def get_child_watcher(self):
|
def get_child_watcher(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue