Closed
Description
The Python Global Interpreter Lock (GIL) only lets one thread execute Python code at the time.
So when using threading
with pure Python, the code is actually concurrent, but not parallel.
When running non Python code, such as the C code of libscip, the GIL can be realsed, allowing threading
to have some level of parallelism.
In Cython, this can be done by wrapping C function calls with:
with nogil:
SCIPsolve(self._scip)
However, one needs to make sure that no Python code is executed when releasing the GIL. This can be hard for two reasons:
- Cython generates some Python code which can be hard to distinguish from C code;
- The GIL needs to be reacquired in all Python callbacks such as BranchRule
Metadata
Metadata
Assignees
Labels
No labels