10000 gh-100227: Make the Global PyModuleDef Cache Safe for Isolated Interpreters by ericsnowcurrently · Pull Request #103084 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-100227: Make the Global PyModuleDef Cache Safe for Isolated Interpreters #103084

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Add _PyThreadState_InitDetached().
  • Loading branch information
ericsnowcurrently committed Mar 27, 2023
commit acf5269bdf94009f72ae8650f6253398d9b6fbb7
1 change: 1 addition & 0 deletions Include/internal/pycore_pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ PyAPI_FUNC(void) _PyThreadState_Bind(PyThreadState *tstate);
PyAPI_FUNC(void) _PyThreadState_Init(
PyThreadState *tstate);
PyAPI_FUNC(void) _PyThreadState_DeleteExcept(PyThreadState *tstate);
extern void _PyThreadState_InitDetached(PyThreadState *, PyInterpreterState *);


static inline void
Expand Down
14 changes: 14 additions & 0 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,20 @@ _PyThreadState_Init(PyThreadState *tstate)
Py_FatalError("_PyThreadState_Init() is for internal use only");
}

void
_PyThreadState_InitDetached(PyThreadState *tstate, PyInterpreterState *interp)
{
_PyRuntimeState *runtime = interp->runtime;

HEAD_LOCK(runtime);
interp->threads.next_unique_id += 1;
uint64_t id = interp->threads.next_unique_id;
HEAD_UNLOCK(runtime);

init_threadstate(tstate, interp, id);
// We do not call add_threadstate().
}

void
PyThreadState_Clear(PyThreadState *tstate)
{
Expand Down
0