sys.exit() and PyRun_SimpleFileExFlags()

Xavier Bénech xavier.benech at t-immersion.com
Fri Jul 10 01:39:07 CEST 2009


Hi,

There is a behaviour I do not understand of PyRun_SimpleFileExFlags(), 
normally when it executes a python script containing a sys.exit(), it 
results by ending the calling application.

I have got this behaviour with PyRun_SimpleFileExFlags() when I call it 
from the main thread of a GUI application (so I use PyRun_FileExFlags() 
in this case).

But in another application when it is called 
(PyRun_SimpleFileExFlags())) from a working thread (not the main one) of 
a console application, everything just go fine without exiting the 
application nor the thread. It returns the exit code specified in 
sys.exit() just fine.

Last things, I am working on Windows. And for the story, I started to 
make a small function to wrap some embedded python script call using the 
simple way with PyRun_SimpleFileExFlags() for the second application, 
but when I integrate it in the first one (with GUI) got some problems 
(:)) so I redo things with a cleaner PyRun_FileExFlags() call.

So, my question is: why do I have different behaviour of 
PyRun_SimpleFileExFlags() in this two cases?

Regards,
Xavier Benech.




More information about the Python-list mailing list