Closed TXYH1 closed 3 years ago
Hi,my environment is: system: Ubuntu 18.04.5 LTS golang: go1.14 linux/amd64 python version: Python 2.7.17
func init() { err := python.Initialize() if err != nil { panic(err.Error()) } } func main(){ m := python.PyImport_AddModule("sys") if m == nil { panic("fail to import module sys") } path := m.GetAttrString("path") if path == nil { panic("fail to get path") } curPath := python.PyString_FromString("/home/zjf/demopj/python") python.PyList_Insert(path, 0, curPath) m = python.PyImport_ImportModule("pyDemo") if m == nil { panic("fail to import module pyDemo") } func_abc := m.GetAttrString("print_abc") if func_abc == nil { panic("fail to get func_abc") } go func() { for { func_abc.CallFunction() time.Sleep(time.Millisecond) } }() go func() { for { func_abc.CallFunction() time.Sleep(time.Millisecond) } }() select { } }
python code:
def print_abc(): return "abc"
Fatal Python error: GC object already tracked or fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x7fbec21f9da9]
Can you help me? Thank you very much.
presumably, that's the CPython's GIL showing its ugly head. you need to serialize calls to the CPython interpreter.
https://realpython.com/python-gil/
okay, thank you
Hi,my environment is: system: Ubuntu 18.04.5 LTS golang: go1.14 linux/amd64 python version: Python 2.7.17
go code:
python code:
when run the go code, it panic stable, like:
Fatal Python error: GC object already tracked or fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x7fbec21f9da9]
Can you help me? Thank you very much.