summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authortwisteroid ambassador <twisteroidambassador@users.noreply.github.com>2018-10-10 17:25:58 (GMT)
committerYury Selivanov <yury@magic.io>2018-10-10 17:25:58 (GMT)
commita14dda5df62369d01db6c7519e73aae71d0e7cfe (patch)
treeaa432c57bce9f18b3325f82efd1984470197827e /Lib/asyncio
parente7ebf1453beb1a40e65630897fa1e35a3c2d3ec1 (diff)
downloadcpython-a14dda5df62369d01db6c7519e73aae71d0e7cfe.zip
cpython-a14dda5df62369d01db6c7519e73aae71d0e7cfe.tar.gz
cpython-a14dda5df62369d01db6c7519e73aae71d0e7cfe.tar.bz2
[3.6] bpo-34769: Thread safety for _asyncgen_finalizer_hook(). (GH-9716) (GH-9792)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/base_events.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 30ac592..accd669 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -368,10 +368,7 @@ class BaseEventLoop(events.AbstractEventLoop):
def _asyncgen_finalizer_hook(self, agen):
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()
+ self.call_soon_threadsafe(self.create_task, agen.aclose())
def _asyncgen_firstiter_hook(self, agen):
if self._asyncgens_shutdown_called: