mirror of https://github.com/go-python/gopy.git
Release GIL in function generator
Signed-off-by: Oleksii Moskalenko <moskalenko.alexey@gmail.com>
This commit is contained in:
parent
0b356cbc43
commit
d8c8eee594
|
@ -260,6 +260,14 @@ func (g *pyGen) genFuncBody(sym *symbol, fsym *Func) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// release GIL
|
||||
g.gofile.Printf("_saved_thread := C.PyEval_SaveThread()\n")
|
||||
if !rvIsErr && nres != 2 {
|
||||
// reacquire GIL after return
|
||||
g.gofile.Printf("defer C.PyEval_RestoreThread(_saved_thread)\n")
|
||||
}
|
||||
|
||||
if isMethod {
|
||||
g.gofile.Printf(
|
||||
`vifc, __err := gopyh.VarFromHandleTry((gopyh.CGoHandle)(_handle), "%s")
|
||||
|
@ -407,6 +415,9 @@ if __err != nil {
|
|||
|
||||
if rvIsErr || nres == 2 {
|
||||
g.gofile.Printf("\n")
|
||||
// reacquire GIL
|
||||
g.gofile.Printf("C.PyEval_RestoreThread(_saved_thread)\n")
|
||||
|
||||
g.gofile.Printf("if __err != nil {\n")
|
||||
g.gofile.Indent()
|
||||
g.gofile.Printf("estr := C.CString(__err.Error())\n")
|
||||
|
|
Loading…
Reference in New Issue