Restart crashing modules in windows

A

Astan Chee

Hi,
I have a python module that keeps on crashing with various windows
errors (not BSOD but the less lethal windows XP popup ones). Now these
are intentional and rather sporadic so I cant really solve it by
attempting to fix the crash; rather what Im trying to do is make another
module outside it that restarts this module every time it crashes. Is
this possible? How do I do this? Or does one windows crash in one python
module crash python entirely and I have to resort in an external program
to restart python everytime it crashes?
Thanks again for all the help.
Astan
 
M

Mike Driscoll

Hi,
I have a python module that keeps on crashing with various windows
errors (not BSOD but the less lethal windows XP popup ones). Now these
are intentional and rather sporadic so I cant really solve it by
attempting to fix the crash; rather what Im trying to do is make another
module outside it that restarts this module every time it crashes. Is
this possible? How do I do this? Or does one windows crash in one python
module crash python entirely and I have to resort in an external program
to restart python everytime it crashes?
Thanks again for all the help.
Astan

If you're not going to catch the error that is causing the crash, then
I think your only option is to restart your application with an
external program. However, maybe someone else will have a better idea.

Mike
 
M

Mike Driscoll

Mike Driscoll wrote:


Hi,
I have a python module that keeps on crashing with various windows
errors (not BSOD but the less lethal windows XP popup ones). Now these
are intentional and rather sporadic so I cant really solve it by
attempting to fix the crash; rather what Im trying to do is make another
module outside it that restarts this module every time it crashes. Is
this possible?

If you're not going to catch the error that is causing the crash, then
I think your only option is to restart your application with an
external program.

My understanding of using an external application to do this is to first
create my module as an executable using py2exe. Then I have another python
script that runs this module like this

while (1):
os.popen("program_module.exe")

and make this other python script into another executable and execute this
one. If Im not mistaken, when the python program crashes, the thread is
killed. is this correct or how should I do it?
Thanks again.
Astan

You'll have to look in Windows Task Manager and see if your
"program_module.exe" is listed after the crash. Press CTRL+Shift+ESC,
right-click a blank spot on the taskbar and choose Task Manager or
press CTRL+ALT+DEL to open it. If your program is not listed, then the
thread is "killed" so-to-speak. Otherwise, it's most likely hung and
you'll have to select it and choose End Process to kill it.

If it is not hung, then you can use the os.popen method to restart it,
but you should really look at subprocess.Popen() instead as it
supersedes os.popen() as of Python 2.4. See http://docs.python.org/lib/module-subprocess.html
for more info.

You might also take a look at IDLE's code as it has a way of stopping
a script using CTRL+C and restarting itself into its original state.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top