summaryrefslogtreecommitdiff
path: root/Lib/idlelib/PyShell.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2003-03-22 19:40:19 +0000
committerKurt B. Kaiser <kbk@shore.net>2003-03-22 19:40:19 +0000
commit11c53e2ea7f7d2a2969c98e81c1489c4e72254c4 (patch)
tree7d39c8ebae64934426779dd7d468ac4688d3e416 /Lib/idlelib/PyShell.py
parente51529d79a5b575e648bf5e6eef5324c8fb819ba (diff)
downloadcpython-git-11c53e2ea7f7d2a2969c98e81c1489c4e72254c4.tar.gz
M PyShell.py
M run.py 1. Move subprocess socket handling to a subthread - "SockThread". 2. In the subprocess, implement a queue and global completion and exit flags. Execute code after it is passed through the queue. (Currently, user code is executed in SockThread. The next phase of development will move the tail of the queue to MainThread.) 3. Implement an RPC message used to shut down the execution server. 4. Improve normal and exception subprocess exits. (At this checkin a "pass loop" interrupt doesn't work on any platform. It will be restored for all platforms once user code execution is moved to MainThread.)
Diffstat (limited to 'Lib/idlelib/PyShell.py')
-rw-r--r--Lib/idlelib/PyShell.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 0c9fbfbcfa..9f158f5a90 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -367,18 +367,14 @@ class ModifiedInterpreter(InteractiveInterpreter):
except:
pass
# Kill subprocess, spawn a new one, accept connection.
- if hasattr(os, 'kill'):
- # We can interrupt any loop if we can use SIGINT. This doesn't
- # work in Windows, currently we can only interrupt loops doing I/O.
- self.__signal_interrupt()
- # XXX KBK 13Feb03 Don't close the socket until the interrupt thread
- # finishes.
- self.tkconsole.executing = False
try:
+ self.interrupt_subprocess()
+ self.shutdown_subprocess()
self.rpcclt.close()
os.wait()
except:
pass
+ self.tkconsole.executing = False
self.spawn_subprocess()
self.rpcclt.accept()
self.transfer_path()
@@ -406,16 +402,32 @@ class ModifiedInterpreter(InteractiveInterpreter):
pass
def __request_interrupt(self):
- self.rpcclt.asynccall("exec", "interrupt_the_server", (), {})
+ try:
+ self.rpcclt.asynccall("exec", "interrupt_the_server", (), {})
+ except:
+ pass
def interrupt_subprocess(self):
- if hasattr(os, "kill"):
+ # XXX KBK 22Mar03 Use interrupt message on all platforms for now.
+ # XXX if hasattr(os, "kill"):
+ if False:
self.__signal_interrupt()
else:
# Windows has no os.kill(), use an RPC message.
# This is async, must be done in a thread.
threading.Thread(target=self.__request_interrupt).start()
+ def __request_shutdown(self):
+ try:
+ self.rpcclt.asynccall("exec", "shutdown_the_server", (), {})
+ except:
+ pass
+
+ def shutdown_subprocess(self):
+ t = threading.Thread(target=self.__request_shutdown)
+ t.start()
+ t.join()
+
def transfer_path(self):
self.runcommand("""if 1:
import sys as _sys
@@ -468,9 +480,10 @@ class ModifiedInterpreter(InteractiveInterpreter):
def kill_subprocess(self):
clt = self.rpcclt
- self.rpcclt = None
if clt is not None:
+ self.shutdown_subprocess()
clt.close()
+ self.rpcclt = None
debugger = None