File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -260,6 +260,14 @@ func (g *pyGen) genFuncBody(sym *symbol, fsym *Func) {
260
260
}
261
261
}
262
262
}
263
+
264
+ // release GIL
265
+ g .gofile .Printf ("_saved_thread := C.PyEval_SaveThread()\n " )
266
+ if ! rvIsErr && nres != 2 {
267
+ // reacquire GIL after return
268
+ g .gofile .Printf ("defer C.PyEval_RestoreThread(_saved_thread)\n " )
269
+ }
270
+
263
271
if isMethod {
264
272
g .gofile .Printf (
265
273
`vifc, __err := gopyh.VarFromHandleTry((gopyh.CGoHandle)(_handle), "%s")
@@ -407,6 +415,9 @@ if __err != nil {
407
415
408
416
if rvIsErr || nres == 2 {
409
417
g .gofile .Printf ("\n " )
418
+ // reacquire GIL
419
+ g .gofile .Printf ("C.PyEval_RestoreThread(_saved_thread)\n " )
420
+
410
421
g .gofile .Printf ("if __err != nil {\n " )
411
422
g .gofile .Indent ()
412
423
g .gofile .Printf ("estr := C.CString(__err.Error())\n " )
You can’t perform that action at this time.
0 commit comments