Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 036e849

Browse files
committed
#5492: Avoid traceback when exiting IDLE caused by a race condition.
1 parent 3886120 commit 036e849

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

Lib/idlelib/PyShell.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ def __init__(self, tkconsole):
367367
self.port = PORT
368368
self.original_compiler_flags = self.compile.compiler.flags
369369

370+
_afterid = None
370371
rpcclt = None
371372
rpcsubproc = None
372373

@@ -486,6 +487,8 @@ def interrupt_subprocess(self):
486487
threading.Thread(target=self.__request_interrupt).start()
487488

488489
def kill_subprocess(self):
490+
if self._afterid is not None:
491+
self.tkconsole.text.after_cancel(self._afterid)
489492
try:
490493
self.rpcclt.listening_sock.close()
491494
except AttributeError: # no socket
@@ -561,8 +564,8 @@ def poll_subprocess(self):
561564
pass
562565
# Reschedule myself
563566
if not self.tkconsole.closing:
564-
self.tkconsole.text.after(self.tkconsole.pollinterval,
565-
self.poll_subprocess)
567+
self._afterid = self.tkconsole.text.after(
568+
self.tkconsole.pollinterval, self.poll_subprocess)
566569

567570
debugger = None
568571

@@ -973,10 +976,6 @@ def close(self):
973976
self.stop_readline()
974977
self.canceled = True
975978
self.closing = True
976-
# Wait for poll_subprocess() rescheduling to stop
977-
self.text.after(2 * self.pollinterval, self.close2)
978-
979-
def close2(self):
980979
return EditorWindow.close(self)
981980

982981
def _close(self):

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ Library
8181
IDLE
8282
----
8383

84+
- Issue #5492: Avoid traceback when exiting IDLE caused by a race condition.
85+
8486
- Issue #17511: Keep IDLE find dialog open after clicking "Find Next".
8587
Original patch by Sarah K.
8688

0 commit comments

Comments
 (0)