summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/run.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2004-01-21 18:54:30 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2004-01-21 18:54:30 (GMT)
commitaf3eb878027954fa578f43ba490599d13215eb3a (patch)
tree799909d784c98e4ff9151eee29e9609cf045bc33 /Lib/idlelib/run.py
parent1fe97502002823098f66c9f103c8e27c8bcc69f9 (diff)
downloadcpython-af3eb878027954fa578f43ba490599d13215eb3a.zip
cpython-af3eb878027954fa578f43ba490599d13215eb3a.tar.gz
cpython-af3eb878027954fa578f43ba490599d13215eb3a.tar.bz2
Added a Tk error dialog to run.py inform the user if the subprocess can't
connect to the user GUI process. Added a timeout to the GUI's listening socket. Added Tk error dialogs to PyShell.py to announce a failure to bind the port or connect to the subprocess. Clean up error handling during connection initiation phase. This is an update of Python Patch 778323. M NEWS.txt M PyShell.py M ScriptBinding.py M run.py Backport candidate.
Diffstat (limited to 'Lib/idlelib/run.py')
-rw-r--r--Lib/idlelib/run.py31
1 files changed, 23 insertions, 8 deletions
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 8cfa808..96da459 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -47,6 +47,7 @@ def main(del_exitfunc=False):
global no_exitfunc
no_exitfunc = del_exitfunc
port = 8833
+ #time.sleep(15) # test subprocess not responding
if sys.argv[1:]:
port = int(sys.argv[1])
sys.argv[:] = [""]
@@ -90,24 +91,38 @@ def main(del_exitfunc=False):
continue
def manage_socket(address):
- for i in range(6):
+ for i in range(3):
time.sleep(i)
try:
server = MyRPCServer(address, MyHandler)
break
except socket.error, err:
- if i < 3:
- print>>sys.__stderr__, ".. ",
- else:
- print>>sys.__stderr__,"\nPython subprocess socket error: "\
- + err[1] + ", retrying...."
+ print>>sys.__stderr__,"IDLE Subprocess: socket error: "\
+ + err[1] + ", retrying...."
else:
- print>>sys.__stderr__, "\nConnection to Idle failed, exiting."
+ print>>sys.__stderr__, "IDLE Subprocess: Connection to "\
+ "IDLE GUI failed, exiting."
+ show_socket_error(err, address)
global exit_now
exit_now = True
return
server.handle_request() # A single request only
+def show_socket_error(err, address):
+ import Tkinter
+ import tkMessageBox
+ root = Tkinter.Tk()
+ root.withdraw()
+ if err[0] == 61: # connection refused
+ msg = "IDLE's subprocess can't connect to %s:%d. This may be due "\
+ "to your personal firewall configuration. It is safe to "\
+ "allow this internal connection because no data is visible on "\
+ "external ports." % address
+ tkMessageBox.showerror("IDLE Subprocess Error", msg, parent=root)
+ else:
+ tkMessageBox.showerror("IDLE Subprocess Error", "Socket Error: %s" % err[1])
+ root.destroy()
+
def print_exception():
import linecache
linecache.checkcache()
@@ -116,7 +131,7 @@ def print_exception():
typ, val, tb = excinfo = sys.exc_info()
sys.last_type, sys.last_value, sys.last_traceback = excinfo
tbe = traceback.extract_tb(tb)
- print >>efile, '\nTraceback (most recent call last):'
+ print>>efile, '\nTraceback (most recent call last):'
exclude = ("run.py", "rpc.py", "threading.py", "Queue.py",
"RemoteDebugger.py", "bdb.py")
cleanup_traceback(tbe, exclude)