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 — gh-59956: Clarify Runtime State Status Expectations by ericsnowcurrently · Pull Request #101308 · python/cpython

Conversation

@ericsnowcurrently

@ericsnowcurrently ericsnowcurrently commented Jan 25, 2023 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

A PyThreadState can be in one of many states in its lifecycle, represented by some status value. Those statuses haven't been particularly clear, so we're addressing that here. Specifically:

  • made the distinct lifecycle statuses clear on PyThreadState
  • identified expectations of how various lifecycle-related functions relate to status
  • noted the various places where those expectations don't match the actual behavior

At some point we'll need to address the mismatches.

(This change also includes some cleanup.)

  • Issue: [subinterpreters] Make the PyGILState API compatible with subinterpreters #59956

Sorry, something went wrong.

Uh oh!

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

All reactions
@ericsnowcurrently ericsnowcurrently added the skip news label Jan 25, 2023
@bedevere-bot bedevere-bot added the awaiting core review label Jan 25, 2023
@bedevere-bot bedevere-bot mentioned this pull request Jan 25, 2023
[subinterpreters] Make the PyGILState API compatible with subinterpreters #59956
Open
@ericsnowcurrently
ericsnowcurrently force-pushed the pystate-lifecycle-cleanup branch from 38fe407 to 8375a8d Compare January 25, 2023 00:46
@ericsnowcurrently
ericsnowcurrently marked this pull request as draft January 25, 2023 15:47
@ericsnowcurrently
ericsnowcurrently force-pushed the pystate-lifecycle-cleanup branch from fbb4556 to 575a299 Compare January 25, 2023 17:25
ericsnowcurrently added 24 commits January 25, 2023 15:08
@ericsnowcurrently
Factor out tstate_verify_not_active().
b64ce9f
@ericsnowcurrently
Drop the check_current param from _PyThreadState_Delete().
1be0ec4
@ericsnowcurrently
Drop _PyThreadState_Delete().
3454bf1
@ericsnowcurrently
Unset the "current" thread state before zapping the threads instead o…
a929e32
…f after.
@ericsnowcurrently
Only clear the current thread if the interpreter matches.
e6ddd92
@ericsnowcurrently
Always "check_current" in zapthreads().
36c512f
@ericsnowcurrently
Do not pass the runtime to _PyThreadState_DeleteExcept().
d402a82
@ericsnowcurrently
Add some notes, TODO comments, and asserts.
2ddfe71
@ericsnowcurrently
Mark the main interpreter as finalizing during runtime fini.
99de509
@ericsnowcurrently
Add more notes and TODO comments.
b77ae5e
@ericsnowcurrently
Make PyThreadState._status more granular.
9ca673c
@ericsnowcurrently
Add more status fields.
8a71957
@ericsnowcurrently
Add a TODO.
62d1a93
@ericsnowcurrently
Track active status.
90cea92
@ericsnowcurrently
Clarify a TODO comment.
9965813
@ericsnowcurrently
Associate "bound" and "active".
fd5048b
@ericsnowcurrently
_PyThreadState_Prealloc() -> _PyThreadState_New()
2105cd6
@ericsnowcurrently
Factor out tstate_tss_*().
8b110cf
@ericsnowcurrently
current_tss_*() -> gilstate_tss_*().
ca98d68
@ericsnowcurrently
Add bind_gilstate_tstate() and unbind_gilstate_tstate().
4f39976
@ericsnowcurrently
Update some TODO comments.
6e73669
@ericsnowcurrently
Clean up _PyThreadState_Swap() a little.
cc3540d
@ericsnowcurrently
Fix the stable ABI.
1ce3841
@ericsnowcurrently
Fixes for multiprocessing.
121d328
ericsnowcurrently added 7 commits January 25, 2023 15:08
@ericsnowcurrently
Move a comment.
8666362
@ericsnowcurrently
Preserve errno more carefully.
52ac2d9
@ericsnowcurrently
Do not call bind_gilstate_tstate() in bind_tstate().
f7ac19a
@ericsnowcurrently
Add an assert.
a338248
@ericsnowcurrently
Clean up bind_gilstate_tstate().
5be78e9
@ericsnowcurrently
Clear bound_gilstate for the old thread state.
f019bd6
@ericsnowcurrently
bound_gilstate and gilstate_tss_get() must match.
6869bfe
@ericsnowcurrently
ericsnowcurrently force-pushed the pystate-lifecycle-cleanup branch from 575a299 to 6869bfe Compare January 25, 2023 22:08
ericsnowcurrently added 4 commits January 25, 2023 15:16
@ericsnowcurrently
Add a blank line for clarity.
f91d458
@ericsnowcurrently
Do not call unbind_gilstate_tstate() in unbind_tstate().
9b45398
@ericsnowcurrently
Fix comments.
98a2dae
@ericsnowcurrently
Fix padding.
afde196
@ericsnowcurrently
ericsnowcurrently marked this pull request as ready for review January 30, 2023 18:56
@ericsnowcurrently
ericsnowcurrently merged commit e11fc03 into python:main Jan 30, 2023
@bedevere-bot bedevere-bot removed the awaiting core review label Jan 30, 2023
@ericsnowcurrently
ericsnowcurrently deleted the pystate-lifecycle-cleanup branch January 30, 2023 19:07
@ericsnowcurrently ericsnowcurrently mentioned this pull request Jan 30, 2023
Requiring A Current Thread State for PyThreadState_Clear(), etc. is Problematic #101436
Open
mdboom pushed a commit to mdboom/cpython that referenced this pull request Jan 31, 2023
@ericsnowcurrently @mdboom
pythongh-59956: Clarify Runtime State Status Expectations (pythongh-1…
29348d0
…01308)

A PyThreadState can be in one of many states in its lifecycle, represented by some status value.  Those statuses haven't been particularly clear, so we're addressing that here.  Specifically:

* made the distinct lifecycle statuses clear on PyThreadState
* identified expectations of how various lifecycle-related functions relate to status
* noted the various places where those expectations don't match the actual behavior

At some point we'll need to address the mismatches.

(This change also includes some cleanup.)

python#59956
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

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.

2 participants

@ericsnowcurrently @bedevere-bot
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.