[pypy-dev] pypy c++ embedding multithread GIL

手游引擎组|田凯 tkn0313 at corp.netease.com
Wed Oct 19 23:58:48 EDT 2016


My program is programed mixing with python and c++.

Program runs in pypy, using c++ extending( mylib.so). mylib.so is multi-threaded. How could I get pypy GIL to ensure sync when c++ calls python function ?
My program runs flow as example: Is there any other api or my use is wrong ? 

python code:
def work_callback():
pass
def work():
lib.cpp_work() 

c++ code: (thread func, multi thread will call cpp_work)
void cpp_work()
{
//how to get pypy GIL ( I ues PyGILState_Ensure but blocked here for ever)
work_callback() //call python func
//release GIL (PyGILState_Release(state)
}
2016-10-20
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20161020/ff8e0eb7/attachment.html>


More information about the pypy-dev mailing list