Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Commit f5ab2bb

Browse files
committed
Handle if async generators are GCed from another thread.
_asyncgen_finalizer_hook should wake up the loop in case it was called from another thread.
1 parent e3fed68 commit f5ab2bb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

asyncio/base_events.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ def _asyncgen_finalizer_hook(self, agen):
351351
self._asyncgens.discard(agen)
352352
if not self.is_closed():
353353
self.create_task(agen.aclose())
354+
# Wake up the loop if the finalizer was called from
355+
# a different thread.
356+
self._write_to_self()
354357

355358
def _asyncgen_firstiter_hook(self, agen):
356359
if self._asyncgens_shutdown_called:

0 commit comments

Comments
 (0)