[issue31388] Provide a way to defer SIGINT handling in the current thread

Nathaniel Smith report at bugs.python.org
Fri Sep 8 13:27:58 EDT 2017


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 <report at bugs.python.org>
<https://bugs.python.org/issue31388>
_______________________________________


More information about the Python-bugs-list mailing list