mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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.
This commit is contained in:
parent
1fe9750200
commit
af3eb87802
4 changed files with 96 additions and 56 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue