Mercurial > cpython-lru_cache-weakref
diff Lib/idlelib/PyShell.py @ 25123:6b67d26079f2 legacy-trunk
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.
| author | Kurt B. Kaiser <kbk@shore.net> |
|---|---|
| date | Thu, 05 Sep 2002 02:31:20 +0000 |
| parents | f059d5435d65 |
| children | 4b6185128814 |
line wrap: on
line diff
--- a/Lib/idlelib/PyShell.py Thu Sep 05 01:14:07 2002 +0000 +++ b/Lib/idlelib/PyShell.py Thu Sep 05 02:31:20 2002 +0000 @@ -187,17 +187,19 @@ 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 @@ 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 @@ 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 @@ 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 @@ self.history = self.History(self.text) if use_subprocess: - self.interp.spawn_subprocess() + self.interp.start_subprocess() reading = 0 executing = 0
