Skip to content

gh-40440: Add a timeout parameter to tkinter wait_variable() - #152619

Draft
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-40440-wait-variable-timeout
Draft

serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-40440-wait-variable-timeout

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Misc.wait_variable() wraps the Tcl tkwait variable command, which blocks until the variable is written — with no escape if that never happens (e.g. the application is torn down before the setter runs), so the call can hang forever.

Add an optional keyword-only timeout argument (in seconds).
With a timeout the wait is reimplemented in Python on top of tkapp.dooneevent() and a variable trace: it returns True if the variable was modified, or False if the timeout elapsed first (or the application was destroyed while waiting).
Without a timeout the behaviour is unchanged (the native tkwait call, always returns True).

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Oct 5, 2026
Without a timeout wait_variable() blocks forever if the variable is never
set, for example because the window that would set it was destroyed.  The
new keyword-only timeout parameter bounds the wait and returns whether the
variable was modified.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka
serhiy-storchaka force-pushed the gh-40440-wait-variable-timeout branch from 3afa68b to 7ffa1a4 Compare November 26, 2026 15:41
@serhiy-storchaka
serhiy-storchaka marked this pull request as draft November 26, 2026 16:00
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant