]> granicus.if.org Git - python/commitdiff
#5492: Avoid traceback when exiting IDLE caused by a race condition.
authorRoger Serwy <roger.serwy@gmail.com>
Wed, 12 Jun 2013 03:13:17 +0000 (22:13 -0500)
committerRoger Serwy <roger.serwy@gmail.com>
Wed, 12 Jun 2013 03:13:17 +0000 (22:13 -0500)
Lib/idlelib/PyShell.py
Misc/NEWS

index e9cef9b884adbaf6487009398dae6e1bcb9e122a..7f2b775f4561e295818e661e88e45aef4f625a47 100644 (file)
@@ -367,6 +367,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
         self.port = PORT
         self.original_compiler_flags = self.compile.compiler.flags
 
+    _afterid = None
     rpcclt = None
     rpcsubproc = None
 
@@ -486,6 +487,8 @@ class ModifiedInterpreter(InteractiveInterpreter):
         threading.Thread(target=self.__request_interrupt).start()
 
     def kill_subprocess(self):
+        if self._afterid is not None:
+            self.tkconsole.text.after_cancel(self._afterid)
         try:
             self.rpcclt.listening_sock.close()
         except AttributeError:  # no socket
@@ -561,8 +564,8 @@ class ModifiedInterpreter(InteractiveInterpreter):
                 pass
         # Reschedule myself
         if not self.tkconsole.closing:
-            self.tkconsole.text.after(self.tkconsole.pollinterval,
-                                      self.poll_subprocess)
+            self._afterid = self.tkconsole.text.after(
+                self.tkconsole.pollinterval, self.poll_subprocess)
 
     debugger = None
 
@@ -973,10 +976,6 @@ class PyShell(OutputWindow):
         self.stop_readline()
         self.canceled = True
         self.closing = True
-        # Wait for poll_subprocess() rescheduling to stop
-        self.text.after(2 * self.pollinterval, self.close2)
-
-    def close2(self):
         return EditorWindow.close(self)
 
     def _close(self):
index 50937a99ae67c6bf0630eecdc52998a0b7fee8e8..cd76c4c6238f9c7084d1a3cc944b8a7c66fbd023 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -81,6 +81,8 @@ Library
 IDLE
 ----
 
+- Issue #5492: Avoid traceback when exiting IDLE caused by a race condition.
+
 - Issue #17511: Keep IDLE find dialog open after clicking "Find Next".
   Original patch by Sarah K.