Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement PEP 788#133110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
ZeroIntensity wants to merge67 commits intopython:main
base:main
Choose a base branch
Loading
fromZeroIntensity:pep-788-impl
Draft
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
67 commits
Select commitHold shift + click to select a range
1828b9a
Implement interpreter state reference counting.
ZeroIntensityApr 24, 2025
d0895f9
Add a test for interpreter reference counts.
ZeroIntensityApr 24, 2025
5c3ee8d
Add thread state daemon-ness that doesn't work yet.
ZeroIntensityApr 25, 2025
7b9ac59
Add untested implementation of non-daemon native threads.
ZeroIntensityApr 25, 2025
0868c15
Add a test for PyThreadState_SetDaemon().
ZeroIntensityApr 25, 2025
e9ea644
Add untested implementation of Ensure()/Release() that probably doesn…
ZeroIntensityApr 25, 2025
0ebdca4
Change some comments.
ZeroIntensityApr 25, 2025
40989de
Add a test that I'm sure doesn't work.
ZeroIntensityApr 25, 2025
d501f35
Use the interpreter's reference count and native thread countdown as …
ZeroIntensityApr 25, 2025
c5ec89c
Fix the countdown decrement.
ZeroIntensityApr 26, 2025
4e1f599
Remove unused variable.
ZeroIntensityApr 26, 2025
3127a3f
Test for PyGILState_Ensure()
ZeroIntensityApr 26, 2025
82b5b9f
Fix the test for the new reference counting.
ZeroIntensityApr 26, 2025
fda9886
Add PyInterpreterState_Lookup()
ZeroIntensityApr 26, 2025
f7723c0
Fix a few bugs and add a test.
ZeroIntensityApr 26, 2025
62e9549
Add a test for PyThreadState_Ensure() across interpreters.
ZeroIntensityApr 27, 2025
bc60630
Remove an artifact from old approach.
ZeroIntensityApr 28, 2025
9d8d526
Fix test from earlier semantics.
ZeroIntensityApr 28, 2025
54b0ce0
Remove 'daemonness' as a property of a thread.
ZeroIntensityMay 22, 2025
5955de6
Add strong interpreter reference functions.
ZeroIntensityMay 22, 2025
92cf906
Implement weak references.
ZeroIntensityMay 22, 2025
b0d0673
Fix some thread safety issues regarding interpreter deletion.
ZeroIntensityMay 22, 2025
0a15beb
Merge from main branch.
ZeroIntensityMay 22, 2025
16d79de
Implement new version of PyThreadState_Ensure() and PyThreadState_Rel…
ZeroIntensityMay 22, 2025
c2bffcd
Use the new APIs in the tests.
ZeroIntensityMay 22, 2025
911c6b5
Fix _testcapi.
ZeroIntensityMay 22, 2025
b84fa90
Fix the ensure counter.
ZeroIntensityMay 22, 2025
9ccf6bd
Add the test to test_embed.
ZeroIntensityMay 22, 2025
481caf5
Allow the wait to be interrupted by CTRL+C.
ZeroIntensityMay 22, 2025
71e1aec
Print the error before bailing out.
ZeroIntensityMay 22, 2025
d661578
Updates for the new proposal.
ZeroIntensityMay 28, 2025
4249c5d
Bikeshedding.
ZeroIntensityMay 28, 2025
71f2fd7
Apply suggestions from code review
ZeroIntensityMay 28, 2025
03ccb38
Fix failing build.
ZeroIntensityMay 29, 2025
bca65fb
Rename parameter.
ZeroIntensityMay 29, 2025
510ade1
Fix formatting.
ZeroIntensityMay 29, 2025
3971408
Add tstate check.
ZeroIntensityMay 29, 2025
6c4c52b
Move to pycore_pystate.h
ZeroIntensityMay 29, 2025
64920a8
Revert "Move to pycore_pystate.h"
ZeroIntensityMay 29, 2025
05436f3
Use an exponential wait time for the event.
ZeroIntensityMay 29, 2025
02bc2d7
Mark function as static.
ZeroIntensityMay 29, 2025
03fa2af
Update fatal error message.
ZeroIntensityMay 29, 2025
b955d85
Remove incorrect assertion.
ZeroIntensityMay 29, 2025
5236700
Add a comment regarding PyMem_RawMalloc()
ZeroIntensityMay 29, 2025
a277130
Add a comment.
ZeroIntensityJun 1, 2025
dac0c1a
Update Include/cpython/pystate.h
ZeroIntensityJun 1, 2025
ab9e3b5
Merge branch 'pep-788-impl' of https://github.com/ZeroIntensity/cpyth…
ZeroIntensityJun 1, 2025
79a1852
Move some tests around to prevent exposure of the private API.
ZeroIntensityJun 1, 2025
47957b8
Move weakref test to internal C API.
ZeroIntensityJun 1, 2025
771d7ed
Improve reference counting tests.
ZeroIntensityJun 1, 2025
0c3c1c7
Remove dead function.
ZeroIntensityJun 1, 2025
531928e
Add some more tests.
ZeroIntensityJun 1, 2025
08a8af6
Remove unused variables.
ZeroIntensityJun 1, 2025
02f93bc
Fix some thread state attachment problems.
ZeroIntensityJun 1, 2025
d6c82bd
Only delete thread states created by PyThreadState_Ensure()
ZeroIntensityJun 1, 2025
082fd69
Add a test for crossinterpreter ensures.
ZeroIntensityJun 1, 2025
61f70ae
Add a test for weak interpreter references.
ZeroIntensityJun 1, 2025
fa961e9
Fix concurrent shutdown races in PyGILState_Ensure().
ZeroIntensityJun 1, 2025
ea1da77
Add a test for PyInterpreterRef_Main().
ZeroIntensityJun 1, 2025
6f19384
Use PyErr_FormatUnraisable to show signals.
ZeroIntensityJun 1, 2025
b702da2
Fix a re-entrancy deadlock.
ZeroIntensityJun 1, 2025
40e7e68
Remove stupid IDE imports.
ZeroIntensityJun 1, 2025
96efc81
Merge branch 'main' of https://github.com/python/cpython into pep-788…
ZeroIntensityJun 21, 2025
af6f6fd
Merge branch 'pep-788-impl' of https://github.com/ZeroIntensity/cpyth…
ZeroIntensityJun 21, 2025
2c52cdc
Fix interpreter reference count tests.
ZeroIntensityJun 21, 2025
3ffe9d0
Merge branch 'main' of https://github.com/python/cpython into pep-788…
ZeroIntensityJul 9, 2025
588364c
Add thread state references to PyThreadState_Ensure() and
ZeroIntensityJul 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Add PyInterpreterState_Lookup()
  • Loading branch information
@ZeroIntensity
ZeroIntensity committedApr 26, 2025
commitfda9886edd26ed7a7e1946f5030cfe96bcbbe2a6
2 changes: 2 additions & 0 deletionsInclude/cpython/pystate.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -283,6 +283,8 @@ PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc(
* PyThreadState_Ensure() or PyInterpreterState_Release(). */
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Hold(void);

PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Lookup(int64_t interp_id);

/* Release a reference to an interpreter incremented by PyInterpreterState_Hold() */
PyAPI_FUNC(void) PyInterpreterState_Release(PyInterpreterState *interp);

Expand Down
26 changes: 23 additions & 3 deletionsPython/pystate.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3074,9 +3074,6 @@ _PyThreadState_CheckConsistency(PyThreadState *tstate)
int
_PyThreadState_MustExit(PyThreadState *tstate)
{
if (!tstate->daemon) {
return 0;
}
int state = _Py_atomic_load_int_relaxed(&tstate->state);
return state == _Py_THREAD_SHUTTING_DOWN;
}
Expand DownExpand Up@@ -3221,6 +3218,29 @@ PyInterpreterState_Hold(void)
return interp;
}

PyInterpreterState *
PyInterpreterState_Lookup(int64_t interp_id)
{
PyInterpreterState *interp = _PyInterpreterState_LookUpID(interp_id);
if (interp == NULL) {
return NULL;
}
HEAD_LOCK(&_PyRuntime); // Prevent deletion
struct _Py_finalizing_threads finalizing = interp->threads.finalizing;
PyMutex *mutex = &finalizing.mutex;
PyMutex_Lock(mutex); // Synchronize TOCTOU with the event flag
if (_PyEvent_IsSet(&finalizing.finished)) {
/* Interpreter has already finished threads */
interp = NULL;
} else {
_Py_atomic_add_ssize(&finalizing.countdown, 1);
}
PyMutex_Unlock(mutex);
HEAD_UNLOCK(&_PyRuntime);

return interp;
}

void
PyInterpreterState_Release(PyInterpreterState *interp)
{
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp