Depsgraph: release GIL when evaluating the depsgraph

Evaluating the dependency graph potentially executes Python code when
evaluating drivers. In specific situations (see T91046) this could
deadlock Blender entirely. Temporarily releasing the GIL when evaluating
the depsgraph resolves this.

This is an improved version of
rBfc460351170478e712740ae1917a2e24803eba3b, thanks @brecht for the diff!

Manifest task: T91046
This commit is contained in:
2021-09-10 10:57:05 +02:00
parent 93d2940603
commit fe4286435c
3 changed files with 23 additions and 4 deletions

View File

@@ -29,10 +29,9 @@
/* analogue of PyEval_SaveThread() */
BPy_ThreadStatePtr BPY_thread_save(void)
{
/* Use `_PyThreadState_UncheckedGet()`, instead of more canonical `PyGILState_Check()` or
* `PyThreadState_Get()`, to avoid a fatal error issued when a thread state is NULL (the thread
* state can be NULL when quitting Blender). */
if (_PyThreadState_UncheckedGet()) {
/* Don't use `PyThreadState_Get()`, to avoid a fatal error issued when a thread state is NULL
* (the thread state can be NULL when quitting Blender). */
if (PyGILState_Check()) {
return (BPy_ThreadStatePtr)PyEval_SaveThread();
}
return NULL;