Skip to content

Commit a8286a6

Browse files
committed
Attempt to reduce the race condition
1 parent 717044a commit a8286a6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/c/jni/org_jpy_PyLib.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ static int python_traceback_report(PyObject *tb, char **buf, int* bufLen);
5858
#define JPy_GIL_AWARE
5959

6060
#ifdef JPy_GIL_AWARE
61-
#define JPy_BEGIN_GIL_STATE { PyGILState_STATE gilState = PyGILState_Ensure();
61+
#define JPy_BEGIN_GIL_STATE { if (Py_IsFinalizing() != 0) pthread_exit(NULL); PyGILState_STATE gilState = PyGILState_Ensure();
62+
// #define JPy_BEGIN_GIL_STATE { PyGILState_STATE gilState = PyGILState_Ensure();
6263
#define JPy_END_GIL_STATE PyGILState_Release(gilState); }
6364
#else
6465
#define JPy_BEGIN_GIL_STATE

0 commit comments

Comments
 (0)