Skip to content

Conversation

@ZeroIntensity
Copy link
Member

@ZeroIntensityZeroIntensity commented Jun 26, 2025

/* Each of these functions can start one another, e.g. a pending call
* could start a thread or vice versa. To ensure that we properly clean
* call everything, we run these in a loop until none of them run anything. */
for (;){
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to add an arbitrary limit to detect infinite loop? For example, log an error after 16 attemps.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Well, it would prevent deadlocks in rare cases, but it would cause crashes in other equally rare cases. Maybe it would be better to emit a fatal error when there are too many iterations?

Copy link
Member

@ericsnowcurrentlyericsnowcurrently left a comment

Choose a reason for hiding this comment

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

Overall, good work. 😄

I'm pretty sure there's a race we need to deal with which will require a variety of changes to this PR.

@bedevere-app
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@ZeroIntensity
Copy link
MemberAuthor

ZeroIntensity commented Sep 17, 2025

The failing CI jobs are due to Ubuntu being weird, and should disappear when I rerun the job. But I'll take that as a sign that I should run the buildbots before merging this.

@ZeroIntensityZeroIntensity added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 17, 2025
@bedevere-bot

This comment was marked as outdated.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 17, 2025
@ZeroIntensity
Copy link
MemberAuthor

Nevermind, I broke FT when I fixed the merge conflicts. Ugh.

@ZeroIntensityZeroIntensity added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 17, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit e202848 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F136004%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 17, 2025
@ZeroIntensity
Copy link
MemberAuthor

@ericsnowcurrently I'll hold off on merging until we talk tomorrow. We might want to extend the check to subinterpreters, and then disallow creating new interpreters during finalization.

@ZeroIntensityZeroIntensity merged commit 2191497 into python:mainSep 18, 2025
45 checks passed
@ZeroIntensityZeroIntensity deleted the fix-circular-finalization branch September 18, 2025 12:29
@github-project-automationgithub-project-automationbot moved this from Todo to Done in Sprint 2024Sep 18, 2025
ZeroIntensity added a commit that referenced this pull request Sep 18, 2025
…ization (GH-139129) During finalization, we need to mark all non-daemon threads as daemon to quickly shut down threads when sending CTRL^C to the process. This was a minor regression from GH-136004.
encukou added a commit that referenced this pull request Sep 22, 2025
This fixes file descriptor leaks introduced in GH-136004
ZeroIntensity added a commit that referenced this pull request Oct 15, 2025
…ng finalization (GH-140103) This fixes a regression introduced by GH-136004, in which finalization would hang while executing atexit handlers if the system was out of memory. --------- Signed-off-by: yihong0618 <[email protected]> Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
…s during finalization (pythonGH-140103) This fixes a regression introduced by pythonGH-136004, in which finalization would hang while executing atexit handlers if the system was out of memory. --------- Signed-off-by: yihong0618 <[email protected]> Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants

@ZeroIntensity@bedevere-bot@vstinner@ericsnowcurrently@sobolevn