Ask Your Question
2

Python file crashes on the second time

asked 2012-10-15 02:38:14 -0500

Pablo Nicolas gravatar image

updated 2012-10-15 02:38:51 -0500

Hi all, I've done a python file with windows using wxpython library. If I run my python file from PyScripter I´ve no problems. When I run my python file from PSSE (Run Automation File button) I´ve no problems in the first time, but if I run this python file again, it crashes! Anyone knows this problem? I think that the problem is in wxpython library...

Thanks in advance for your help.

Regards, Pablo Nicolás

edit retag flag offensive close merge delete

Comments

Hi Pablo, what kind of crash is it? Does the "windows has detected a problem" box come up?

JervisW gravatar imageJervisW ( 2012-10-15 17:40:59 -0500 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2012-11-01 10:12:14 -0500

jsexauer gravatar image

My guess would be some kind of variable is getting hosed up. When you run a script in PyScripter and then run it again, PyScripter resets Python between the two runs. However, PSSE runs the script the second time from where the first run left off, so all the variables are still in scope.

To test this, run your script, then run the commands below, then run your script again. If it works fine, you know that its because of how your script is leaving the variables when it exits.

import sys
this = sys.modules[__name__]
for n in dir():
    if n[0]!='_': delattr(this, n)
edit flag offensive delete link more

Comments

It works! Thank you very much!!! But I close my window with the next instruction: frame.Close(True) How should I close the window?

Pablo Nicolas gravatar imagePablo Nicolas ( 2012-11-02 05:59:54 -0500 )edit
1

change the last line to be:

if n[0]!='_' and n!='frame': delattr(this, n)

jsexauer gravatar imagejsexauer ( 2012-11-02 10:15:57 -0500 )edit

FYI, my original solution was to prove that the problem is with your variables not clearing between runs. You should figure out why they need to be initialized. Probably you're assuming a var is false because it wasn't declared until that moment in the 1st run, but has a value is set in the 2nd

jsexauer gravatar imagejsexauer ( 2012-11-02 10:21:13 -0500 )edit

It's solved. Thank you very much!

Pablo Nicolas gravatar imagePablo Nicolas ( 2012-11-09 06:30:28 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Stats

Asked: 2012-10-15 02:38:14 -0500

Seen: 925 times

Last updated: Nov 01 '12