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.12] gh-112826: Fix the threading Module When _thread is Missing _is_main_interpreter() by ericsnowcurrently · Pull Request #112850 · python/cpython

Conversation

@ericsnowcurrently

@ericsnowcurrently ericsnowcurrently commented Dec 7, 2023 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

_thread._is_main_interpreter() was added (and aliased as threading._is_main_interpreter()) after the 3.12.0 release, in gh-110707 (a backport of gh-112661). However, that change did not accommodate cases where users replace the _thread module with a custom version that doesn't have _is_main_interpreter() defined (e.g. gevent).

This change fixes that by falling back to a dummy _is_main_interpreter() that always says "yes". That case is unlikely and the consequences of saying a subinterpreter is the main interpreter, relative to `threading._shutdown(), are almost zero.

(We are fixing this in 3.12 only because it is a regression from the already released 3.12.0. In 3.13 (main) we will only have the note in "What's New".)

  • Issue: gh-105716 breaks greenlet/eventlet #112826

📚 Documentation preview 📚: https://cpython-previews--112850.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
ericsnowcurrently added 2 commits December 7, 2023 11:11
@ericsnowcurrently
Add a dummy _is_main_interpreter() if missing from _thread.
f53e861
@ericsnowcurrently
Add a "What's New" entry.
067f55b
@ericsnowcurrently ericsnowcurrently added the skip news label Dec 7, 2023
@ericsnowcurrently
ericsnowcurrently requested a review from Yhg1s December 7, 2023 18:34
@ericsnowcurrently ericsnowcurrently assigned Yhg1s Dec 7, 2023
@bedevere-app bedevere-app Bot added the awaiting core review label Dec 7, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Dec 7, 2023
gh-105716 breaks greenlet/eventlet #112826
Closed
AlexWaygood
AlexWaygood reviewed Dec 7, 2023
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

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

@ericsnowcurrently ericsnowcurrently mentioned this pull request Dec 7, 2023
gh-112826: Add a "What's New" Entry About _thread._is_main_interpreter #112853
Merged
@ericsnowcurrently @AlexWaygood
Update Doc/whatsnew/3.12.rst
ad0515f
Co-authored-by: Alex Waygood <[email protected]>
Yhg1s
Yhg1s reviewed Dec 7, 2023
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

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

Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

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

Comment thread Lib/test/test_threading.py Resolved

Uh oh!

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

Comment thread Lib/test/test_threading.py Resolved

Uh oh!

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

Comment thread Lib/test/test_threading.py Resolved

Uh oh!

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

hugovk
hugovk reviewed Dec 7, 2023
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

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

ericsnowcurrently and others added 3 commits December 7, 2023 12:25
@ericsnowcurrently @hugovk
Update Doc/whatsnew/3.12.rst
656be20
Co-authored-by: Hugo van Kemenade <[email protected]>
@ericsnowcurrently @Yhg1s
Update Doc/whatsnew/3.12.rst
b12bb92
Co-authored-by: T. Wouters <[email protected]>
@ericsnowcurrently
Clean up the test.
17b0f67
ericsnowcurrently added a commit to ericsnowcurrently/cpython that referenced this pull request Dec 7, 2023
@ericsnowcurrently
Match pythongh-112850.
fcb55da
@ericsnowcurrently
Fix the indent.
98c80b9
Yhg1s
Yhg1s approved these changes Dec 7, 2023
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Dec 7, 2023
@Yhg1s
Yhg1s enabled auto-merge (squash) December 7, 2023 20:08
@Yhg1s
Yhg1s merged commit c0fc88f into python:3.12 Dec 7, 2023
@bedevere-app bedevere-app Bot removed the awaiting merge label Dec 7, 2023
@ericsnowcurrently
ericsnowcurrently deleted the backport-3.12-fix-112826-missing-_thread-_is_main_interpreter branch December 7, 2023 20:21
ericsnowcurrently added a commit that referenced this pull request Dec 7, 2023
@ericsnowcurrently
gh-112826: Add a "What's New" Entry About _thread._is_main_interpreter (
64d8b4c
gh-112853)

As of gh-112661, the threading module expects the _thread module to have a _is_main_interpreter(), which is used in the internal threading._shutdown().  This change causes a problem for anyone that replaces the _thread module with a custom one (only if they don't provide _is_main_interpreter()).  They need to be sure to add it for 3.13+, thus this PR is adding a note in "What's New".

This also forward-ports the "What's New" entry from 3.12 (gh-112850).  Note that we do not also forward-port the fix in that PR.  The fix is there only due to a regression from 3.12.0. There is no regression in 3.13+.
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@ericsnowcurrently @aisk
pythongh-112826: Add a "What's New" Entry About _thread._is_main_inte…
d1cfbb7
…rpreter (pythongh-112853)

As of pythongh-112661, the threading module expects the _thread module to have a _is_main_interpreter(), which is used in the internal threading._shutdown().  This change causes a problem for anyone that replaces the _thread module with a custom one (only if they don't provide _is_main_interpreter()).  They need to be sure to add it for 3.13+, thus this PR is adding a note in "What's New".

This also forward-ports the "What's New" entry from 3.12 (pythongh-112850).  Note that we do not also forward-port the fix in that PR.  The fix is there only due to a regression from 3.12.0. There is no regression in 3.13+.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@ericsnowcurrently @Glyphack
pythongh-112826: Add a "What's New" Entry About _thread._is_main_inte…
d98bb49
…rpreter (pythongh-112853)

As of pythongh-112661, the threading module expects the _thread module to have a _is_main_interpreter(), which is used in the internal threading._shutdown().  This change causes a problem for anyone that replaces the _thread module with a custom one (only if they don't provide _is_main_interpreter()).  They need to be sure to add it for 3.13+, thus this PR is adding a note in "What's New".

This also forward-ports the "What's New" entry from 3.12 (pythongh-112850).  Note that we do not also forward-port the fix in that PR.  The fix is there only due to a regression from 3.12.0. There is no regression in 3.13+.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk left review comments
@AlexWaygood AlexWaygood AlexWaygood left review comments
@Yhg1s Yhg1s Yhg1s approved these changes

Uh oh!

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

Assignees

@Yhg1s Yhg1s

Labels

skip news

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.

4 participants

@ericsnowcurrently @hugovk @Yhg1s @AlexWaygood
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.