Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
prange() dead-locks with memoryviews when not freeing the GIL #2798
import numpy as np from cython.parallel import prange def wrapper(): # will hold forever a = np.random.uniform(0, 100, size=(100, 100)).astype(np.int32) g(a) cdef int f(int [:] a_i) nogil: # uses 1d view return 3 cdef int g (int [:, :] a) nogil: cdef: int i for i in prange(a.shape): # Works OK with range f(a[i])
As a workaround we can still pass
Thanks for all the work on Cython!
Thanks for the report, I can reproduce this. My guess is that it dead-locks somehow. Note that you are not freeing the GIL anywhere. I think it's trying to acquire the GIL while it already holds it, or something like that. Ideally, Cython should be able to detect that somehow, but I can't say how difficult that would be.
The GIL is a lock. It is held when entering your Python function (which allows you to do Python stuff and call NumPy functions, for example). You declared the