[C++-sig] how to use PyRun_SimpleFile in a multithread C++ program?

Stefan Seefeld seefeld at sympatico.ca
Mon Sep 18 14:41:33 CEST 2006


jack833 wrote:
> Hi,Every one,
> i need help about PyRun_simplefile function,the program i'm writing  is a
> C++ program which will start serveral threads .each thread will use
> PyRun_simplefile function to do something,but python script file is the
> same.
> now the program is offten crash down,but there is no problem while only
> thread which use PyRun_simplefile,but that is not what i wanted. is there
> anyone who can tell me how to resove it. 

Yes. You have to serialize access to the python runtime as it isn't fully
thread-safe: http://docs.python.org/api/threads.html

HTH,
		Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...



More information about the Cplusplus-sig mailing list