mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
1. Revert subprocess environment clearing, will restart subprocess
instead. 2. Preserve the Idle client's listening socket for reuse with the fresh subprocess. 3. Remove some unused rpc code, comment out additional unused code. Modified Files: ScriptBinding.py rpc.py run.py
This commit is contained in:
parent
a552e3a0c9
commit
adc63847e4
3 changed files with 17 additions and 39 deletions
|
@ -147,8 +147,6 @@ class ScriptBinding:
|
|||
flist = self.editwin.flist
|
||||
shell = flist.open_shell()
|
||||
interp = shell.interp
|
||||
# clear the subprocess environment before every Run/F5 invocation
|
||||
interp.rpcclt.remotecall("exec", "clear_the_environment", (), {})
|
||||
# XXX Too often this discards arguments the user just set...
|
||||
interp.runcommand("""if 1:
|
||||
_filename = %s
|
||||
|
|
|
@ -49,15 +49,16 @@ def pickle_code(co):
|
|||
ms = marshal.dumps(co)
|
||||
return unpickle_code, (ms,)
|
||||
|
||||
def unpickle_function(ms):
|
||||
return ms
|
||||
# XXX KBK 24Aug02 function pickling capability not used in Idle
|
||||
# def unpickle_function(ms):
|
||||
# return ms
|
||||
|
||||
def pickle_function(fn):
|
||||
assert isinstance(fn, type.FunctionType)
|
||||
return `fn`
|
||||
# def pickle_function(fn):
|
||||
# assert isinstance(fn, type.FunctionType)
|
||||
# return `fn`
|
||||
|
||||
copy_reg.pickle(types.CodeType, pickle_code, unpickle_code)
|
||||
copy_reg.pickle(types.FunctionType, pickle_function, unpickle_function)
|
||||
# copy_reg.pickle(types.FunctionType, pickle_function, unpickle_function)
|
||||
|
||||
BUFSIZE = 8*1024
|
||||
|
||||
|
@ -66,8 +67,6 @@ class RPCServer(SocketServer.TCPServer):
|
|||
def __init__(self, addr, handlerclass=None):
|
||||
if handlerclass is None:
|
||||
handlerclass = RPCHandler
|
||||
# XXX KBK 25Jun02 Not used in Idlefork.
|
||||
# self.objtable = objecttable
|
||||
SocketServer.TCPServer.__init__(self, addr, handlerclass)
|
||||
|
||||
def server_bind(self):
|
||||
|
@ -86,18 +85,6 @@ class RPCServer(SocketServer.TCPServer):
|
|||
def get_request(self):
|
||||
"Override TCPServer method, return already connected socket"
|
||||
return self.socket, self.server_address
|
||||
|
||||
|
||||
# XXX The following two methods are not currently used in Idlefork.
|
||||
# def register(self, oid, object):
|
||||
# self.objtable[oid] = object
|
||||
|
||||
# def unregister(self, oid):
|
||||
# try:
|
||||
# del self.objtable[oid]
|
||||
# except KeyError:
|
||||
# pass
|
||||
|
||||
|
||||
objecttable = {}
|
||||
|
||||
|
@ -405,16 +392,17 @@ class RPCClient(SocketIO):
|
|||
nextseq = 1 # Requests coming from the client are odd numbered
|
||||
|
||||
def __init__(self, address, family=socket.AF_INET, type=socket.SOCK_STREAM):
|
||||
self.sock = socket.socket(family, type)
|
||||
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
self.sock.bind(address)
|
||||
self.sock.listen(1)
|
||||
self.listening_sock = socket.socket(family, type)
|
||||
self.listening_sock.setsockopt(socket.SOL_SOCKET,
|
||||
socket.SO_REUSEADDR, 1)
|
||||
self.listening_sock.bind(address)
|
||||
self.listening_sock.listen(1)
|
||||
|
||||
def accept(self):
|
||||
newsock, address = self.sock.accept()
|
||||
working_sock, address = self.listening_sock.accept()
|
||||
if address[0] == '127.0.0.1':
|
||||
print>>sys.__stderr__, "Idle accepted connection from ", address
|
||||
SocketIO.__init__(self, newsock)
|
||||
SocketIO.__init__(self, working_sock)
|
||||
else:
|
||||
print>>sys.__stderr__, "Invalid host: ", address
|
||||
raise socket.error
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import sys
|
||||
import time
|
||||
import socket
|
||||
import __main__
|
||||
import rpc
|
||||
|
||||
def main():
|
||||
|
@ -56,18 +55,11 @@ class Executive:
|
|||
|
||||
def __init__(self, rpchandler):
|
||||
self.rpchandler = rpchandler
|
||||
self.base_env_keys = __main__.__dict__.keys()
|
||||
import __main__
|
||||
self.locals = __main__.__dict__
|
||||
|
||||
def runcode(self, code):
|
||||
exec code in __main__.__dict__
|
||||
|
||||
def clear_the_environment(self):
|
||||
global __main__
|
||||
env = __main__.__dict__
|
||||
for key in env.keys():
|
||||
if key not in self.base_env_keys:
|
||||
del env[key]
|
||||
env['__doc__'] = None
|
||||
exec code in self.locals
|
||||
|
||||
def start_the_debugger(self, gui_adap_oid):
|
||||
import RemoteDebugger
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue