New submission from Sebastian Berg <sebast...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue41037>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to