[Python-checkins] cpython (2.7): #5492: Avoid traceback when exiting IDLE caused by a race condition.

roger.serwy python-checkins at python.org
Wed Jun 12 05:13:36 CEST 2013


http://hg.python.org/cpython/rev/ca8e86711403
changeset:   84095:ca8e86711403
branch:      2.7
user:        Roger Serwy <roger.serwy at gmail.com>
date:        Tue Jun 11 22:13:17 2013 -0500
summary:
  #5492: Avoid traceback when exiting IDLE caused by a race condition.

files:
  Lib/idlelib/PyShell.py |  11 +++++------
  Misc/NEWS              |   2 ++
  2 files changed, 7 insertions(+), 6 deletions(-)


diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -370,6 +370,7 @@
         self.port = PORT
         self.original_compiler_flags = self.compile.compiler.flags
 
+    _afterid = None
     rpcclt = None
     rpcpid = None
 
@@ -497,6 +498,8 @@
         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.close()
         except AttributeError:  # no socket
@@ -569,8 +572,8 @@
                 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
 
@@ -987,10 +990,6 @@
         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):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -50,6 +50,8 @@
 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.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list