summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/run.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2002-07-26 00:06:42 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2002-07-26 00:06:42 (GMT)
commitb417936d4080004b6a7811fb411c6f77db4cc262 (patch)
tree0f36813466ebe3c7f58f7cc0ee7244b9558570a2 /Lib/idlelib/run.py
parentdb40afaabe09062fcf0ff683a9f5ed7df275fd40 (diff)
downloadcpython-b417936d4080004b6a7811fb411c6f77db4cc262.zip
cpython-b417936d4080004b6a7811fb411c6f77db4cc262.tar.gz
cpython-b417936d4080004b6a7811fb411c6f77db4cc262.tar.bz2
Reverse the RPC socket connection: Python execution server connects to
Idle client and localhost origin of connection is verified by client. M PyShell.py M rpc.py M run.py
Diffstat (limited to 'Lib/idlelib/run.py')
-rw-r--r--Lib/idlelib/run.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 9f26c16..5db652e 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -1,13 +1,44 @@
import sys
+import time
+import socket
import rpc
def main():
+ """Start the Python execution server in a subprocess
+
+ In Idle, RPCServer is instantiated with handlerclass MyHandler, which
+ inherits register/unregister methods from RPCHandler via the mix-in class
+ SocketIO.
+
+ When the RPCServer is instantiated, the TCPServer initialization creates an
+ instance of run.MyHandler and calls its handle() method. handle()
+ instantiates a run.Executive, passing it a reference to the MyHandler
+ object. That reference is saved as an attribute of the Executive instance.
+ The Executive methods have access to the reference and can pass it on to
+ entities that they command (e.g. RemoteDebugger.Debugger.start_debugger()).
+ The latter, in turn, can call MyHandler(SocketIO) register/unregister
+ methods via the reference to register and unregister themselves.
+
+ """
port = 8833
if sys.argv[1:]:
port = int(sys.argv[1])
sys.argv[:] = [""]
addr = ("localhost", port)
- svr = rpc.RPCServer(addr, MyHandler)
+ for i in range(12):
+ time.sleep(i)
+ try:
+ svr = rpc.RPCServer(addr, MyHandler)
+ break
+ except socket.error, err:
+ if i < 5:
+ print>>sys.__stderr__, ".. ",
+ else:
+ print>>sys.__stderr__,"\nPython subprocess socket error: "\
+ + err[1] + ", retrying...."
+ else:
+ print>>sys.__stderr__, "\nConnection to Idle failed, exiting."
+ sys.exit()
svr.handle_request() # A single request only
class MyHandler(rpc.RPCHandler):