Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f18939a
Initial fix.
ZeroIntensity Nov 10, 2024
756bf41
Remove junk file.
ZeroIntensity Nov 10, 2024
45c4561
Merge branch 'main' of https://github.com/python/cpython into interp-…
ZeroIntensity Nov 10, 2024
a94eaef
Don't overwrite the main thread.
ZeroIntensity Nov 10, 2024
206b581
Small changes.
ZeroIntensity Nov 10, 2024
286e536
Put lock around exception capturing.
ZeroIntensity Nov 10, 2024
2fab7af
Add a comment.
ZeroIntensity Nov 10, 2024
446abc1
Add blurb.
ZeroIntensity Nov 10, 2024
cc36e8d
Add a test.
ZeroIntensity Nov 10, 2024
e25587e
Skip test on the default build.
ZeroIntensity Nov 10, 2024
e4b2c79
Fix and move tests.
ZeroIntensity Nov 10, 2024
aeb483e
Somehow, the locks are re-entrant.
ZeroIntensity Nov 10, 2024
92b3ea7
Don't rely on the interpreter state for _PyXI_ERR_ALREADY_RUNNING
ZeroIntensity Nov 11, 2024
804c41e
Throw an exception if there's a remaining thread state.
ZeroIntensity Nov 11, 2024
2edfda3
Remove newline.
ZeroIntensity Nov 11, 2024
bb8feee
Remove another newline.
ZeroIntensity Nov 11, 2024
5968448
Add docstrings.
ZeroIntensity Nov 11, 2024
9ab979d
Protect _PyIndexPool_AllocIndex with the runtime lock.
ZeroIntensity Nov 11, 2024
b478375
Bump the thread count.
ZeroIntensity Nov 11, 2024
f393ab6
Add comments to the test.
ZeroIntensity Nov 11, 2024
35323f8
Re-enable subinterpreter tests for the free-threaded build.
ZeroIntensity Nov 11, 2024
67df772
Fix tests.
ZeroIntensity Nov 11, 2024
13e96de
Lock runtime instead of using pyatomic
ZeroIntensity Nov 11, 2024
c9e7b08
Fix failing builds.
ZeroIntensity Nov 11, 2024
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
Prev Previous commit
Next Next commit
Small changes.
  • Loading branch information
ZeroIntensity committed Nov 10, 2024
commit 206b58167e0ffcabb166d06c1dc64d55a65bc8fa
2 changes: 1 addition & 1 deletion Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ _PyXI_Enter(_PyXI_session *session,
// be more efficient to leave the exception in place and return
// immediately. However, life is simpler if we don't.
#ifdef Py_GIL_DISABLED
errcode = _PyInterpreterState_IsRunningAllowed(interp)
errcode = _PyInterpreterState_IsRunningAllowed(interp) == 1
? _PyXI_ERR_ALREADY_RUNNING
: _PyXI_ERR_SHUTTING_DOWN;
#else
Expand Down
14 changes: 7 additions & 7 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,20 +1047,20 @@ get_main_thread(PyInterpreterState *interp)
return _Py_atomic_load_ptr_relaxed(&interp->threads.main);
}

#define _PyInterpreterState_RUNNING_OK 0
#define _PyInterpreterState_RUNNING_PREVENTED 1

int
_PyInterpreterState_IsRunningAllowed(PyInterpreterState *interp)
{
assert(interp != NULL);
#ifdef Py_GIL_DISABLED
return !_Py_atomic_load_int_relaxed(&interp->threads.prevented);
return _Py_atomic_load_int(&interp->threads.prevented) == _PyInterpreterState_RUNNING_OK;
#else
return 1;
#endif
}

#define _PyInterpreterState_RUNNING_OK 0
#define _PyInterpreterState_RUNNING_PREVENTED 1

int
_PyInterpreterState_PreventMain(PyInterpreterState *interp)
{
Expand Down Expand Up @@ -1096,14 +1096,14 @@ _PyInterpreterState_PreventMain(PyInterpreterState *interp)
int
_PyInterpreterState_SetRunningMain(PyInterpreterState *interp)
{
if (_PyInterpreterState_FailIfRunningMain(interp) < 0) {
return -1;
}
if (!_PyInterpreterState_IsRunningAllowed(interp))
{
PyErr_SetString(PyExc_RuntimeError, "cannot run this interpreter anymore");
return -1;
}
if (_PyInterpreterState_FailIfRunningMain(interp) < 0) {
return -1;
}
PyThreadState *tstate = current_fast_get();
_Py_EnsureTstateNotNULL(tstate);
if (tstate->interp != interp) {
Expand Down