[Python-checkins] cpython (3.6): Issue #28500: Fix asyncio to handle async gens GC from another thread.

yury.selivanov python-checkins at python.org
Fri Oct 21 17:14:23 EDT 2016


https://hg.python.org/cpython/rev/3908f432d0ac
changeset:   104618:3908f432d0ac
branch:      3.6
parent:      104616:126ff1f3b6cd
user:        Yury Selivanov <yury at magic.io>
date:        Fri Oct 21 17:13:40 2016 -0400
summary:
  Issue #28500: Fix asyncio to handle async gens GC from another thread.

files:
  Lib/asyncio/base_events.py |  3 +++
  Misc/NEWS                  |  2 ++
  2 files changed, 5 insertions(+), 0 deletions(-)


diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -351,6 +351,9 @@
         self._asyncgens.discard(agen)
         if not self.is_closed():
             self.create_task(agen.aclose())
+            # Wake up the loop if the finalizer was called from
+            # a different thread.
+            self._write_to_self()
 
     def _asyncgen_firstiter_hook(self, agen):
         if self._asyncgens_shutdown_called:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -38,6 +38,8 @@
 
 - Issue #28492: Fix how StopIteration exception is raised in _asyncio.Future.
 
+- Issue #28500: Fix asyncio to handle async gens GC from another thread.
+
 Build
 -----
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list