GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [3.15] gh-161712: Read the clock once in ThreadHandle_join() by aozmekik · Pull Request #161771 · python/cpython

Conversation

@aozmekik

@aozmekik aozmekik commented Nov 10, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Py_MAX() evaluates _PyDeadline_Get() twice. If the deadline passes between the two calls, the first value passes the > 0 check and the second, negative one becomes the timeout, which PyEvent_WaitTimed() takes as no timeout, so Thread.join(timeout) blocks forever. main has read the clock once since gh-157495 (GH-157591), which wasn't backported because it was a cleanup. This is that hunk, with a NEWS entry.

The window is too small to hit from a test, so I forced it under gdb: a signal wakes the join loop of join(3.0) after a second, and the second clock read in that loop reports the deadline as passed. On 3.15 as it is, the join was still blocked after 30 seconds. With this change it returns after 3 seconds. test_threading and test_thread pass.

  • Issue: Thread.join(timeout) can block forever: ThreadHandle_join reads the clock twice through Py_MAX (3.13, 3.14) #161712

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@aozmekik
[3.15] pythongh-161712: Read the clock once in ThreadHandle_join()
fd9c0ba
Py_MAX() evaluated _PyDeadline_Get() twice. If the deadline passed
between the two calls, the negative second value was used as the
timeout, which means no timeout, and Thread.join(timeout) could block
forever. main already reads it once since pythongh-157495.
@bedevere-app bedevere-app Bot mentioned this pull request Nov 10, 2026
Thread.join(timeout) can block forever: ThreadHandle_join reads the clock twice through Py_MAX (3.13, 3.14) #161712
Open
@bedevere-app bedevere-app Bot added the awaiting review label Nov 10, 2026
@ZeroIntensity

ZeroIntensity commented Nov 11, 2026

Copy link
Copy Markdown
Member

This looks good, but please open a new PR against the main branch; even though main isn't affected, it's nice to have consistency across branches (and it makes backporting easier). I think there was talk of reverting #157591 anyway, so it'd be good to have future-proofing in place (especially if there's no test case).

I'm going to close this so you're not tempted to change the base or head branch (doing so would ping all the codeowners!). Feel free to tag me on the new PR, and I'll merge it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ZeroIntensity ZeroIntensity closed this Nov 11, 2026
@aozmekik aozmekik mentioned this pull request Nov 11, 2026
gh-161712: Read the clock once in ThreadHandle_join() #161794
Closed
@ZeroIntensity ZeroIntensity reopened this Nov 11, 2026
ZeroIntensity
ZeroIntensity approved these changes Nov 11, 2026
View reviewed changes

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Sorry, I didn't realize that this already happened on main a little while ago.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Nov 11, 2026
@ZeroIntensity
ZeroIntensity enabled auto-merge (squash) November 11, 2026 16:46
@masenf masenf mentioned this pull request Nov 11, 2026
Don't wait in Thread.join(timeout) when draining supervised output reflex-dev/reflex#7855
Merged
6 tasks done
@ZeroIntensity ZeroIntensity added the needs backport to 3.14 bugs and security fixes label Nov 12, 2026
@ZeroIntensity
ZeroIntensity merged commit 88d137a into python:3.15 Nov 12, 2026
137 of 157 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 12, 2026
@miss-islington-app

miss-islington-app Bot commented Nov 12, 2026

Copy link
Copy Markdown

Thanks @aozmekik for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Nov 12, 2026

Copy link
Copy Markdown

GH-161843 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ZeroIntensity ZeroIntensity ZeroIntensity approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@aozmekik @ZeroIntensity
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.