summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authortwisteroid ambassador <twisteroidambassador@users.noreply.github.com>2018-10-09 15:30:21 (GMT)
committerYury Selivanov <yury@magic.io>2018-10-09 15:30:21 (GMT)
commitc880ffe7d2ce2fedb1831918c8a36e3623e0fb76 (patch)
treefeb0b9505af0d13fd5284514383e0a68a7dbc730 /Lib/asyncio
parent79d21331e605fdc941f947621846b8563485aab6 (diff)
downloadcpython-c880ffe7d2ce2fedb1831918c8a36e3623e0fb76.zip
cpython-c880ffe7d2ce2fedb1831918c8a36e3623e0fb76.tar.gz
cpython-c880ffe7d2ce2fedb1831918c8a36e3623e0fb76.tar.bz2
bpo-34769: Thread safety for _asyncgen_finalizer_hook(). (GH-9716)
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 780a061..3726c55 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -477,10 +477,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: