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 — bpo-37878: Make PyThreadState_DeleteCurrent() Internal by nanjekyejoannah · Pull Request #15315 · python/cpython

bpo-37878: Make PyThreadState_DeleteCurrent() Internal #15315

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.

Sign up for GitHub

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
vstinner merged 10 commits into python:master from nanjekyejoannah:doc_1
Sep 5, 2019

Uh oh!

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

Merged

bpo-37878: Make PyThreadState_DeleteCurrent() Internal #15315

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
10 commits
Select commit Hold shift + click to select a range
35941ef
Document PyThreadState_DeleteCurrent()
nanjekyejoannah Aug 16, 2019
d27549f
📜🤖 Added by blurb_it.
blurb-it[bot] Aug 16, 2019
61ab0c3
Update Doc/c-api/init.rst
nanjekyejoannah Aug 17, 2019
5034af8
Update Doc/c-api/init.rst
nanjekyejoannah Aug 17, 2019
b4d0cce
make pyThreadState_DeleteCurrent internal
nanjekyejoannah Aug 28, 2019
04677dd
Update 2019-08-16-20-01-10.bpo-37878.MvA6rZ.rst
nanjekyejoannah Aug 28, 2019
a38b2b8
remove state from t_bootstrap()
nanjekyejoannah Sep 5, 2019
19c7468
Remove update
nanjekyejoannah Sep 5, 2019
7972bb4
Merge branch 'master' of https://github.com/python/cpython into doc_1
nanjekyejoannah Sep 5, 2019
7acf1cb
resolve merge conflict
nanjekyejoannah Sep 5, 2019
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

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

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

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

Diff view
Diff view

There are no files selected for viewing

3 changes: 3 additions & 0 deletions 3 Doc/whatsnew/3.9.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ Removed
standard :class:`bytes` objects are always used.
(Contributed by Jon Janzen in :issue:`36409`.)

* ``PyThreadState_DeleteCurrent()`` has been removed. It was not documented.
(Contributed by Joannah Nanjekye in :issue:`37878`.)


Porting to Python 3.9
=====================
Expand Down
2 changes: 2 additions & 0 deletions 2 Include/internal/pycore_pylifecycle.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ PyAPI_FUNC(void) _PyErr_Print(PyThreadState *tstate);
PyAPI_FUNC(void) _PyErr_Display(PyObject *file, PyObject *exception,
PyObject *value, PyObject *tb);

PyAPI_FUNC(void) _PyThreadState_DeleteCurrent(_PyRuntimeState *runtime);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 0 additions & 1 deletion 1 Include/pystate.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*);
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);

/* Get the current thread state.

Expand Down
1 change: 1 addition & 0 deletions 1 Misc/NEWS.d/next/Documentation/2019-08-16-20-01-10.bpo-37878.MvA6rZ.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make :c:func:`PyThreadState_DeleteCurrent` Internal.
9 changes: 7 additions & 2 deletions 9 Modules/_threadmodule.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -993,18 +993,21 @@ struct bootstate {
PyObject *args;
PyObject *keyw;
PyThreadState *tstate;
_PyRuntimeState *runtime;
};

static void
t_bootstrap(void *boot_raw)
{
struct bootstate *boot = (struct bootstate *) boot_raw;
PyThreadState *tstate;
_PyRuntimeState *runtime;
PyObject *res;

runtime = boot->runtime;
tstate = boot->tstate;
tstate->thread_id = PyThread_get_thread_ident();
_PyThreadState_Init(&_PyRuntime, tstate);
_PyThreadState_Init(runtime, tstate);
PyEval_AcquireThread(tstate);
tstate->interp->num_threads++;
res = PyObject_Call(boot->func, boot->args, boot->keyw);
Expand All @@ -1025,13 +1028,14 @@ t_bootstrap(void *boot_raw)
PyMem_DEL(boot_raw);
tstate->interp->num_threads--;
PyThreadState_Clear(tstate);
PyThreadState_DeleteCurrent();
_PyThreadState_DeleteCurrent(runtime);
PyThread_exit_thread();
}

static PyObject *
thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
{
_PyRuntimeState *runtime = &_PyRuntime;
PyObject *func, *args, *keyw = NULL;
struct bootstate *boot;
unsigned long ident;
Expand Down Expand Up @@ -1062,6 +1066,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
boot->args = args;
boot->keyw = keyw;
boot->tstate = _PyThreadState_Prealloc(boot->interp);
boot->runtime = runtime;
if (boot->tstate == NULL) {
PyMem_DEL(boot);
return PyErr_NoMemory();
Expand Down
4 changes: 2 additions & 2 deletions 4 Modules/_tracemalloc.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static struct {
#if defined(TRACE_RAW_MALLOC)
/* This lock is needed because tracemalloc_free() is called without
the GIL held from PyMem_RawFree(). It cannot acquire the lock because it
would introduce a deadlock in PyThreadState_DeleteCurrent(). */
would introduce a deadlock in _PyThreadState_DeleteCurrent(). */
static PyThread_type_lock tables_lock;
# define TABLES_LOCK() PyThread_acquire_lock(tables_lock, 1)
# define TABLES_UNLOCK() PyThread_release_lock(tables_lock)
Expand Down Expand Up @@ -728,7 +728,7 @@ tracemalloc_free(void *ctx, void *ptr)
return;

/* GIL cannot be locked in PyMem_RawFree() because it would introduce
a deadlock in PyThreadState_DeleteCurrent(). */
a deadlock in _PyThreadState_DeleteCurrent(). */

alloc->free(alloc->ctx, ptr);

Expand Down
12 changes: 3 additions & 9 deletions 12 Python/pystate.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ PyThreadState_Clear(PyThreadState *tstate)
}


/* Common code for PyThreadState_Delete() and PyThreadState_DeleteCurrent() */
/* Common code for PyThreadState_Delete() and _PyThreadState_DeleteCurrent() */
static void
tstate_delete_common(_PyRuntimeState *runtime, PyThreadState *tstate)
{
Expand Down Expand Up @@ -858,14 +858,14 @@ PyThreadState_Delete(PyThreadState *tstate)
}


static void
void
_PyThreadState_DeleteCurrent(_PyRuntimeState *runtime)
{
struct _gilstate_runtime_state *gilstate = &runtime->gilstate;
PyThreadState *tstate = _PyRuntimeGILState_GetThreadState(gilstate);
if (tstate == NULL)
Py_FatalError(
"PyThreadState_DeleteCurrent: no current tstate");
"_PyThreadState_DeleteCurrent: no current tstate");
tstate_delete_common(runtime, tstate);
if (gilstate->autoInterpreterState &&
PyThread_tss_get(&gilstate->autoTSSkey) == tstate)
Expand All @@ -876,12 +876,6 @@ _PyThreadState_DeleteCurrent(_PyRuntimeState *runtime)
PyEval_ReleaseLock();
}

void
PyThreadState_DeleteCurrent()
{
_PyThreadState_DeleteCurrent(&_PyRuntime);
}


/*
* Delete all thread states except the one passed as argument.
Expand Down
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 01402520 — 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.