From PyPy document, we should do the following: In main process: rpython_startup_code();
Hi, Our scenario is we had a main process, and it will create severl worker threads. Python code is running in worker threads. pypy_init_threads(); pypy_setup_home(...) And in worker thread that need to execute python code: pypy_thread_attach(); However, the problem is the code of the main process is in another module that we don't have source code access. So I am thinking could we do PyPy initialize and Finalize in thread itself? We could run python code in thread one by one. The process looks like: Main process create thread pool -> thread 1 initialized Pypy-> thread 1 run Python code -> thread 1 finish -> thread 1 finalize Pypy -> thread 2 initialized Pypy -> thread 2 run Python code -> thread 2 finish -> thread 2 finialize Pypy ... For now, if we do initialize again in thread 2, it will hang. And if we don't do initilize in thread 2, it will core dump by segmatation fault.