[issue33605] Detect accessing event loop from a different thread outside of _debug

Yury Selivanov report at bugs.python.org
Tue May 22 16:19:53 EDT 2018


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

> I suggest that asyncio should be stricter about this error and that methods and functions that operate on the event loop, such as call_soon, call_later, create_task, ensure_future, and close, should all call _check_thread() even when not in debug mode. _check_thread() warns that it "should only be called when self._debug == True", hinting at "performance reasons", but that doesn't seem justified. threading.get_ident() is efficiently implemented in C, and comparing that integer to another cached integer is about as efficient an operation as it gets.

I'd be OK with this if the performance penalty is within 0.5% in microbenchmarks for asyncio & uvloop.

----------

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


More information about the Python-bugs-list mailing list