[issue34769] _asyncgen_finalizer_hook running in wrong thread

Yury Selivanov report at bugs.python.org
Mon Oct 1 11:43:53 EDT 2018


Yury Selivanov <yselivanov at gmail.com> added the comment:

Wow.  Thanks so much for figuring this out, I know how hard it is to debug issues like this.

Now I see it clearly: _asyncgen_finalizer_hook should be using loop.call_soon_threadsafe.  Interestingly, I used _write_to_self there, so I knew about the issue, but figured that using call_soon() + _write_to_self is safe enough; evidently I was wrong.

Anyways, here's the diff that fixed it for me: https://gist.github.com/1st1/c1c9fc853cac1fadb7102ccc6201fb70

Could you please create a PR (ideally with a unittest)?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34769>
_______________________________________


More information about the Python-bugs-list mailing list