Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python: Ensure that we have the GIL in a callback
Python <3.7 required a call to PyEval_InitThreads() before acquiring the GIL once per thread. Callbacks are potentially issued from a different thread and therefore we need to call this function in callback routines. Unfortunately, calling PyEval_InitThreads() is too late in Cython, as other operations needing the GIL already took place. As workaround, we cimport cython.parallel, which does the same thing in a slightly different way (see cython/cython#2205 (comment)). Starting with Python 3.7, none of this is required any more, as PyEval_InitThreads() is always called. https://vstinner.github.io/python37-gil-change.html has some background on it. Fixes #37
- Loading branch information