Nathaniel Smith added the comment:

... it's true I did write such an example. And a few lines up in the same 
message I wrote an example where I was protecting an event loop from 
interrupts. In both cases the tricky question is how to manage the transitions 
between protected and unprotected without race conditions. Context-local state 
is a great solution for part of this problem.

I did realize this morning that technically it is *possible* to make a plain 
thread local work: you have to move all the state management into task context. 
So each time you start a task, wrap it in a helper that enables interrupts, and 
in early lowest level function that yields, reenable interrupts. This seems a 
bit pointless if we have context local state available though, because using 
context local state adds zero overhead to yields, and we yield approximately 
10,000,000x more frequently than we receive SIGINT.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31388>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to