Embedding python in multithreaded C application

前端 未结 3 1913
臣服心动
臣服心动 2020-12-03 10:48

I\'m embedding the python interpreter in a multithreaded C application and I\'m a little confused as to what APIs I should use to ensure thread safety.

From what I g

3条回答
  •  醉梦人生
    2020-12-03 11:16

    Eventually I figured it out.
    After

    PyEval_InitThreads();
    

    You need to call

    PyEval_SaveThread();
    

    While properly release the GIL for the main thread.

提交回复
热议问题