[New-bugs-announce] [issue41037] Add (optional) threadstate to: PyOS_InterruptOccurred()

Sebastian Berg report at bugs.python.org
Fri Jun 19 10:11:55 EDT 2020


New submission from Sebastian Berg <sebastian at sipsolutions.net>:

In https://bugs.python.org/issue40826 it was defined that `PyOS_InterruptOccurred()` can only be called with a GIL.  NumPy had a few places with very unsafe sigint handling (not thread-safe).  But generally when we are in a situation that catching sigints would be nice as an enhancement, we do of course not hold the GIL.

So I am wondering if we can find some kind of thread-safe solution, or even just recipe.  Briefly looking at the code, it seemed to me that adding a new function with an additional `tstate` signature:

    PyOS_InterruptOccurred(PyThreadState *tstate)

Could work, and be a simple way to allow this in the future?  It is probably not high priority for us (NumPy had only one place where it tried to stop long running computations).
But right now I am unsure if the function has much use if it requires the GIL to be held and a `tstate=NULL` argument seemed reasonable (if it works), except that it adds a C-API name.

----------
components: C API
messages: 371885
nosy: seberg, vstinner
priority: normal
severity: normal
status: open
title: Add (optional) threadstate to: PyOS_InterruptOccurred()
type: enhancement
versions: Python 3.10

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


More information about the New-bugs-announce mailing list