call Python from a multithreaded DLL
Alexandre Perrin
payou at free.fr
Thu Jul 5 07:20:59 EDT 2001
Hi ! I'm working on a Win 32 Multithreaded DLL (in C++) and I need to call the Python (2.1) interpreter from differents threads of my DLL. It works fine when I call python from the main thread but it crashes when i call python from others threads. Here's a sample :
--------------------------------------------------------------------
#include <python.h>
#include <windows.h>
DWORD WINAPI myThread(LPVOID) {
PyEval_AcquireLock();
PyRun_SimpleString("print \"Crash...\"");
PyEval_ReleaseLock();
}
void main() {
DWORD lpThreadId = 0;
PyEval_InitThreads();
Py_Initialize();
PyRun_SimpleString("print \"OK until now...\"");
hTic = CreateThread( NULL, 0, myThread, NULL, 0, &lpThreadId);
Py_Finalize();
}
If someone can help me...
Payou
More information about the Python-list
mailing list