Blender
V3.3
source
blender
python
generic
bpy_threads.c
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-or-later */
2
10
#include <Python.h>
11
12
#include "../BPY_extern.h"
13
#include "
BLI_utildefines.h
"
14
15
BPy_ThreadStatePtr
BPY_thread_save
(
void
)
16
{
17
/* Use `_PyThreadState_UncheckedGet()` instead of `PyThreadState_Get()`, to avoid a fatal error
18
* issued when a thread state is NULL (the thread state can be NULL when quitting Blender).
19
*
20
* `PyEval_SaveThread()` will release the GIL, so this thread has to have the GIL to begin with
21
* or badness will ensue. */
22
if
(_PyThreadState_UncheckedGet() && PyGILState_Check()) {
23
return
(
BPy_ThreadStatePtr
)PyEval_SaveThread();
24
}
25
return
NULL
;
26
}
27
28
void
BPY_thread_restore
(
BPy_ThreadStatePtr
tstate)
29
{
30
if
(tstate) {
31
PyEval_RestoreThread((PyThreadState *)tstate);
32
}
33
}
BLI_utildefines.h
BPy_ThreadStatePtr
void * BPy_ThreadStatePtr
Definition:
BPY_extern.h:42
NULL
return NULL
Definition:
bmesh_operator_api_inline.h:205
BPY_thread_save
BPy_ThreadStatePtr BPY_thread_save(void)
Definition:
bpy_threads.c:15
BPY_thread_restore
void BPY_thread_restore(BPy_ThreadStatePtr tstate)
Definition:
bpy_threads.c:28
Generated on Tue Oct 22 2024 13:18:25 for Blender by
doxygen
1.9.1