Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The :mod:`tkinter` event loop running at the interactive prompt no longer
polls on Unix if Tcl is threaded. It now waits for events or input, so the
process does not wake up every few milliseconds while idle.
31 changes: 22 additions & 9 deletions Modules/_tkinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3792,18 +3792,31 @@ EventHook(void)
else if (type == FILE_TYPE_DISK) {
break;
}
#else
if (tcl_lock == NULL) {
/* Tcl is threaded and stdin is watched by MyFileProc, so we
can wait for an event or input instead of polling. */
Py_BEGIN_ALLOW_THREADS
tcl_tstate = tstate;
result = Tcl_DoOneEvent(0);
tcl_tstate = NULL;
Py_END_ALLOW_THREADS
}
else
#endif
Py_BEGIN_ALLOW_THREADS
if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1);
tcl_tstate = tstate;
{
Py_BEGIN_ALLOW_THREADS
if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1);
tcl_tstate = tstate;

result = Tcl_DoOneEvent(TCL_DONT_WAIT);
result = Tcl_DoOneEvent(TCL_DONT_WAIT);

tcl_tstate = NULL;
if(tcl_lock)PyThread_release_lock(tcl_lock);
if (result == 0)
Sleep(Tkinter_busywaitinterval);
Py_END_ALLOW_THREADS
tcl_tstate = NULL;
if(tcl_lock)PyThread_release_lock(tcl_lock);
if (result == 0)
Sleep(Tkinter_busywaitinterval);
Py_END_ALLOW_THREADS
}

/* Report an exception raised in a callback, but keep pumping events
instead of returning to the prompt: without readline there is no
Expand Down
Loading