Skip to content

fix(query): validate PY_DISCOVERY_TIMEOUT - #143

Merged
gaborbernat merged 4 commits into
tox-dev:mainfrom
darrenhuai:fix/query-timeout-env
Oct 10, 2026
Merged

gaborbernat merged 4 commits into
tox-dev:mainfrom
darrenhuai:fix/query-timeout-env

Conversation

@darrenhuai

@darrenhuai darrenhuai commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Invalid PY_DISCOVERY_TIMEOUT values can raise ValueError or OverflowError, or cause interpreter queries to time out before they can answer.

Use the default of 15 seconds and log a warning for invalid values, including nan, zero and negative numbers. Accept inf or values above 2,147,483.647 seconds to disable the timeout; this ceiling accommodates subprocess waits that use signed 32-bit milliseconds.

Cache the most recent 128 values to avoid repeated warnings during discovery without retaining an unbounded set of environment values.

darrenhuai and others added 3 commits October 9, 2026 16:37
…ough

The override went float(env["PY_DISCOVERY_TIMEOUT"]) straight into
communicate(), so a typo in the variable took discovery down with it. An
empty or non-numeric value raised ValueError out of from_exe with no
mention of the variable. "nan" raised the thread lock's own ValueError,
"inf" and anything past the platform wait limit OverflowError. "0" or a
negative number made every interpreter time out at once, so discovery
quietly found nothing.

Parse it once. Anything that isn't a positive number of seconds is
ignored with one warning that names the variable, and the default 15
applies. inf, or a value beyond what poll(2) can take in milliseconds,
means no timeout, which is what communicate(None) does. The parse is
cached per value so the warning shows once per process, not once per
interpreter probed.
Long-running callers can supply distinct timeout values without limit.
Bound the parse cache and verify warning eviction through interpreter
queries. Simplify validation and document the subprocess wait ceiling.
@gaborbernat gaborbernat added the bug Something isn't working label Oct 10, 2026
@gaborbernat gaborbernat changed the title 🐛 fix(query): validate PY_DISCOVERY_TIMEOUT instead of passing it through fix(query): validate PY_DISCOVERY_TIMEOUT Oct 10, 2026

@gaborbernat gaborbernat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbernat
gaborbernat enabled auto-merge (squash) October 10, 2026 00:52
@gaborbernat
gaborbernat merged commit 60ddef1 into tox-dev:main Oct 10, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants