Skip to content

Commit

Permalink
Python: Ensure that we have the GIL in a callback
Browse files Browse the repository at this point in the history
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
imphil committed Sep 11, 2019
1 parent 556a7b8 commit 3b24ebc
Show file tree
Hide file tree
Showing 2 changed files with 1,936 additions and 1,883 deletions.
Loading

0 comments on commit 3b24ebc

Please sign in to comment.