Skip to content

Commit

Permalink
bpo-38951: Use threading.main_thread() check in asyncio (GH-17433)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahiuchun authored and miss-islington committed Dec 5, 2019
1 parent bb81549 commit 99eb70a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Lib/asyncio/events.py
Expand Up @@ -636,7 +636,7 @@ def get_event_loop(self):
"""
if (self._local._loop is None 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())

if self._local._loop is None:
Expand Down
5 changes: 2 additions & 3 deletions Lib/asyncio/unix_events.py
Expand Up @@ -1406,8 +1406,7 @@ def _init_watcher(self):
with events._lock:
if self._watcher is None: # pragma: no branch
self._watcher = ThreadedChildWatcher()
if isinstance(threading.current_thread(),
threading._MainThread):
if threading.current_thread() is threading.main_thread():
self._watcher.attach_loop(self._local._loop)

def set_event_loop(self, loop):
Expand All @@ -1421,7 +1420,7 @@ def set_event_loop(self, loop):
super().set_event_loop(loop)

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)

def get_child_watcher(self):
Expand Down

0 comments on commit 99eb70a

Please sign in to comment.