Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-09-10 11:57:05 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-09-10 12:03:54 +0300
commitfe4286435c54b3ba0a031f032b95615da74a7aac (patch)
treeb118d6583176209e6a07c9781b484b622741abd3 /source/blender/python
parent93d2940603121acc47ea9860dac98e4e63c8f1d3 (diff)
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
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/generic/bpy_threads.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/source/blender/python/generic/bpy_threads.c b/source/blender/python/generic/bpy_threads.c
index 57eb3a82c44..54548b88d4f 100644
--- a/source/blender/python/generic/bpy_threads.c
+++ b/source/blender/python/generic/bpy_threads.c
@@ -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;