[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Restart crashing modules in windows

Astan Chee

1/15/2008 3:02:00 AM

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
2 Answers

Mike Driscoll

1/15/2008 2:27:00 PM

0

On Jan 14, 9:02 pm, Astan Chee <st...@al.com.au> 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? 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

Mike Driscoll

1/16/2008 1:52:00 AM

0

On Jan 15, 2008 5:08 PM, Astan Chee <stanc@al.com.au> wrote:
>
> Mike Driscoll wrote:
> On Jan 14, 9:02 pm, Astan Chee <st...@al.com.au> 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-subpr...
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