Le 10/08/2020 à 18:52, Sebastian Berg a écrit :
I am still confused about this. Maybe shorter, we have:
User who release GIL → NumPy API → third-party C function
We can probably assume that the user will use
NumPy APIfrom random threads, but only from threads already running Python (i.e. created by Python), although there may be arguments that exceptions would be nice, I do not think those are a priority.
In that case, is
PyGILState_Ensure()considered safe and appropriate API to be used within "third-party C function" (and/or NumPy API)? I used to generally think its not, but now it seems to me it should be, if the thread we are running on was previously spawned by Python?
PyGILState_Ensure() should always be safe, regardless of who/what
spawned the thread. The only limit is that it doesn't handle