diff options
| author | Armin Rigo <arigo@tunes.org> | 2015-12-06 18:57:54 +0100 |
|---|---|---|
| committer | Armin Rigo <arigo@tunes.org> | 2015-12-06 18:57:54 +0100 |
| commit | 0d6be486fbc420577f70b9db513b93310f3b96bc (patch) | |
| tree | 1e6f9e569a1335094266106e16832dbe6dbf741b /c/call_python.c | |
| parent | 3bfbf9a79e0d5f8c88ea8fad0cc054ccd6f0bd90 (diff) | |
| download | cffi-0d6be486fbc420577f70b9db513b93310f3b96bc.tar.gz | |
Tweak for PyGILState_Ensure(), improving massively its performance in
case it is called repeatedly in a non-python-created thread
Diffstat (limited to 'c/call_python.c')
| -rw-r--r-- | c/call_python.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/c/call_python.c b/c/call_python.c index 33726f3..c4d6f60 100644 --- a/c/call_python.c +++ b/c/call_python.c @@ -180,9 +180,7 @@ static void _cffi_call_python(struct _cffi_externpy_s *externpy, char *args) err = 1; } else { -#ifdef WITH_THREAD - PyGILState_STATE state = PyGILState_Ensure(); -#endif + PyGILState_STATE state = gil_ensure(); if (externpy->reserved1 != PyThreadState_GET()->interp->modules) { /* Update the (reserved1, reserved2) cache. This will fail if we didn't call @ffi.def_extern() in this particular @@ -192,9 +190,7 @@ static void _cffi_call_python(struct _cffi_externpy_s *externpy, char *args) if (!err) { general_invoke_callback(0, args, args, externpy->reserved2); } -#ifdef WITH_THREAD - PyGILState_Release(state); -#endif + gil_release(state); } if (err) { static const char *msg[2] = { |
