[issue31960] Protection against using a Future with another loop only works with await

Yury Selivanov report at bugs.python.org
Tue Nov 7 10:42:09 EST 2017


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

>> I think we should update `Future._schedule_callbacks` to check if the loop is in debug mode.

> Unfortunately this is not sufficient for the snippet I posted.  The loop's thread_id is only set when the loop runs, but the main loop in that example never runs.

If the loop isn't running, call_soon works just fine from any thread.  

call_soon_threadsafe is different from call_soon when the loop *is* running.  When it's running and blocked on IO, call_soon_threadsafe will make sure that the loop will be woken up.

Currently, _schedule_callbacks() calls loop.call_soon(), which already calls loop._check_thread().  So it looks like we don't need to change anything after all, right?

----------
stage: patch review -> 

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


More information about the Python-bugs-list mailing list