diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2002-09-05 02:31:20 +0000 |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2002-09-05 02:31:20 +0000 |
commit | 63857a454d85fda475264575b7c1a031970219a0 (patch) | |
tree | 1b957ef7888fe190e287eeb34dc2bd6922a81a7c /Lib/idlelib/PyShell.py | |
parent | 342456d5d25be692c3ddd43d0446b52555251ccc (diff) | |
download | cpython-git-63857a454d85fda475264575b7c1a031970219a0.tar.gz |
M PyShell.py
M RemoteDebugger.py
M ScriptBinding.py
Restart the execution server with a clean environment and execute the
active module from scratch upon activation of Run/F5.
Add functionality to PyShell.py to restart the execution server in a new
subprocess. The server makes a connection to the Idle client which sends a
block of code to be executed.
Modify ScriptBinding.py to restart the subprocess upon Run/F5, assuming that
an execution is not currently in progress. Remove Import Module functionality,
not required now that the code is executed in a clean environment.
If the Debugger is active, also restart the subprocess side of the split
debugger. Add functionality to RemoteDebugger.py to support this.
At this time breakpoints will be lost in the subprocess if Run/F5 is activated.
A subsequent checkin of PyShell.py will implement reloading of the breakpoints
into the subprocess debugger. I'm keeping this separate as the design may
change.
Diffstat (limited to 'Lib/idlelib/PyShell.py')
-rw-r--r-- | Lib/idlelib/PyShell.py | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index b483ea84e6..9ef2ff7586 100644 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -187,17 +187,19 @@ class ModifiedInterpreter(InteractiveInterpreter): InteractiveInterpreter.__init__(self, locals=locals) self.save_warnings_filters = None + port = 8833 rpcclt = None rpcpid = None def spawn_subprocess(self): - port = 8833 - addr = ("localhost", port) - # Spawn the Python execution "server" w = ['-W' + s for s in sys.warnoptions] args = [sys.executable] + w + ["-c", "__import__('run').main()", - str(port)] + str(self.port)] self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args) + + def start_subprocess(self): + addr = ("localhost", self.port) + self.spawn_subprocess() # Idle starts listening for connection on localhost for i in range(6): time.sleep(i) @@ -221,6 +223,21 @@ class ModifiedInterpreter(InteractiveInterpreter): self.rpcclt.register("flist", self.tkconsole.flist) self.poll_subprocess() + def restart_subprocess(self): + # close only the subprocess debugger + db = self.getdebugger() + if db: + RemoteDebugger.close_subprocess_debugger(self.rpcclt) + # kill subprocess, spawn a new one, accept connection + self.rpcclt.close() + self.spawn_subprocess() + self.rpcclt.accept() + # restart remote debugger + if db: + gui = RemoteDebugger.restart_subprocess_debugger(self.rpcclt) + # reload remote debugger breakpoints + pass # XXX KBK 04Sep02 TBD + active_seq = None def poll_subprocess(self): @@ -383,15 +400,18 @@ class ModifiedInterpreter(InteractiveInterpreter): def getdebugger(self): return self.debugger + def display_executing_dialog(self): + tkMessageBox.showerror( + "Already executing", + "The Python Shell window is already executing a command; " + "please wait until it is finished.", + master=self.tkconsole.text) + def runcommand(self, code): "Run the code without invoking the debugger" # The code better not raise an exception! if self.tkconsole.executing: - tkMessageBox.showerror( - "Already executing", - "The Python Shell window is already executing a command; " - "please wait until it is finished.", - master=self.tkconsole.text) + display_executing_dialog() return 0 if self.rpcclt: self.rpcclt.remotecall("exec", "runcode", (code,), {}) @@ -402,11 +422,7 @@ class ModifiedInterpreter(InteractiveInterpreter): def runcode(self, code): "Override base class method" if self.tkconsole.executing: - tkMessageBox.showerror( - "Already executing", - "The Python Shell window is already executing a command; " - "please wait until it is finished.", - master=self.tkconsole.text) + display_executing_dialog() return # self.checklinecache() @@ -509,7 +525,7 @@ class PyShell(OutputWindow): self.history = self.History(self.text) if use_subprocess: - self.interp.spawn_subprocess() + self.interp.start_subprocess() reading = 0 executing = 0 |