]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38951: Use threading.main_thread() check in asyncio (GH-17433)
authorHill Ma <mahiuchun@users.noreply.github.com>
Thu, 5 Dec 2019 12:40:12 +0000 (04:40 -0800)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 5 Dec 2019 12:40:12 +0000 (04:40 -0800)
https://bugs.python.org/issue38951

Lib/asyncio/events.py
Lib/asyncio/unix_events.py

index 36b7ea307e03bf082fa73f46e872713c86444996..c7343f515ca222688c9af3fd04106c7171d40b7d 100644 (file)
@@ -636,7 +636,7 @@ class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
         """
         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:
index 632546ad00817fdd854bfd96a6eaa7c6d0cc6cd8..97198ea2f4953bc308c7cddd8096cf6198726745 100644 (file)
@@ -1406,8 +1406,7 @@ class _UnixDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
         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):
@@ -1421,7 +1420,7 @@ class _UnixDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
         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):