Skip to content

Instantly share code, notes, and snippets.

@1st1
Created October 1, 2018 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1st1/c1c9fc853cac1fadb7102ccc6201fb70 to your computer and use it in GitHub Desktop.
Save 1st1/c1c9fc853cac1fadb7102ccc6201fb70 to your computer and use it in GitHub Desktop.
Fix bpo-34769
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 492e377d09..3b1ed00af3 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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment