Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Put Tkinter_busywaitinterval into module state
  • Loading branch information
erlend-aasland committed Mar 29, 2023
commit 6610e11236a15bb6a7118ccc2050e89a4ff46ac3
14 changes: 8 additions & 6 deletions Modules/_tkinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,6 @@ Tkinter_Error(TkappObject *self)

/**** Utils ****/

static int Tkinter_busywaitinterval = 20;

#ifndef MS_WINDOWS

/* Millisecond sleep() for Unix platforms. */
Expand Down Expand Up @@ -2753,7 +2751,7 @@ _tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold)
PyThread_release_lock(st->tcl_lock);
}
if (result == 0)
Sleep(Tkinter_busywaitinterval);
Sleep(st->Tkinter_busywaitinterval);
Py_END_ALLOW_THREADS
}

Expand Down Expand Up @@ -3083,7 +3081,8 @@ _tkinter_setbusywaitinterval_impl(PyObject *module, int new_val)
"busywaitinterval must be >= 0");
return NULL;
}
Tkinter_busywaitinterval = new_val;
module_state *st = GLOBAL_STATE();
st->Tkinter_busywaitinterval = new_val;
Py_RETURN_NONE;
}

Expand All @@ -3097,7 +3096,8 @@ static int
_tkinter_getbusywaitinterval_impl(PyObject *module)
/*[clinic end generated code: output=23b72d552001f5c7 input=a695878d2d576a84]*/
{
return Tkinter_busywaitinterval;
module_state *st = GLOBAL_STATE();
return st->Tkinter_busywaitinterval;
}

#include "clinic/_tkinter.c.h"
Expand Down Expand Up @@ -3238,7 +3238,7 @@ EventHook(void)
PyThread_release_lock(st->tcl_lock);
}
if (result == 0)
Sleep(Tkinter_busywaitinterval);
Sleep(st->Tkinter_busywaitinterval);
Py_END_ALLOW_THREADS

if (result < 0)
Expand Down Expand Up @@ -3299,6 +3299,8 @@ PyInit__tkinter(void)
PyObject *m, *uexe, *cexe, *o;

module_state *st = GLOBAL_STATE();
st->Tkinter_busywaitinterval = 20;

st->tcl_lock = PyThread_allocate_lock();
if (st->tcl_lock == NULL)
return NULL;
Expand Down
3 changes: 3 additions & 0 deletions Modules/tkinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ typedef struct {
PyObject *excInCmd;
int errorInCmd;
int quitMainLoop;

// Util
int Tkinter_busywaitinterval;
} module_state;

extern module_state global_state;
Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ Modules/_ctypes/cfield.c - formattable -
Modules/_ctypes/malloc_closure.c - free_list -
Modules/_curses_panel.c - lop -
Modules/_ssl/debughelpers.c _PySSL_keylog_callback lock -
Modules/_tkinter.c - Tkinter_busywaitinterval -
Modules/_tkinter.c - call_mutex -
Modules/_tkinter.c - var_mutex -
Modules/_tkinter.c - command_mutex -
Expand Down