I'm calling a Python script from another program (Stata), which has a command for calling the operating system (shell/winexec). This, in turn, opens a system window where you can see the Python script running. Sometimes the script runs just fine and sometimes it abruptly quits before finishing. I have no idea why. I never have this problem when I run the script in IDLE. I'm using Windows and Python 3.4.
I've tried catching the error by logging the Python script, but no error ever gets recorded there. Everything seems to be working normally until the program just quits (and not always at the same point). Also, I'm calling 7 scripts and only two of them ever have this sudden quitting problem (again, they always run fine through IDLE). I tried changing the order in which I call the scripts and using shell instead of winexec and vise-versa. At this point, I don't even know what to try. Is it the operating system? Python? Stata? Any ideas would be appreciated!