Skip to content

Commit

Permalink
pythongh-121621: Move asyncio_running_loop to private struct
Browse files Browse the repository at this point in the history
This avoids changing the ABI and keeps the field in the private struct.
  • Loading branch information
colesbury committed Jul 17, 2024
1 parent 51da3df commit d623558
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ struct _ts {
pycore_ceval.h. */
uintptr_t eval_breaker;

PyObject *asyncio_running_loop; // Strong reference

struct {
/* Has been initialized to a safe state.
Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_tstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ typedef struct _PyThreadStateImpl {
// semi-public fields are in PyThreadState.
PyThreadState base;

PyObject *asyncio_running_loop; // Strong reference

struct _qsbr_thread_state *qsbr; // only used by free-threaded build
struct llist_node mem_free_queue; // delayed free queue

Expand Down
8 changes: 4 additions & 4 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ get_event_loop(asyncio_state *state)
PyObject *loop;
PyObject *policy;

PyThreadState *ts = _PyThreadState_GET();
_PyThreadStateImpl *ts = (_PyThreadStateImpl *)_PyThreadState_GET();
loop = Py_XNewRef(ts->asyncio_running_loop);

if (loop != NULL) {
Expand Down Expand Up @@ -3278,7 +3278,7 @@ static PyObject *
_asyncio__get_running_loop_impl(PyObject *module)
/*[clinic end generated code: output=b4390af721411a0a input=0a21627e25a4bd43]*/
{
PyThreadState *ts = _PyThreadState_GET();
_PyThreadStateImpl *ts = (_PyThreadStateImpl *)_PyThreadState_GET();
PyObject *loop = Py_XNewRef(ts->asyncio_running_loop);
if (loop == NULL) {
/* There's no currently running event loop */
Expand All @@ -3302,7 +3302,7 @@ static PyObject *
_asyncio__set_running_loop(PyObject *module, PyObject *loop)
/*[clinic end generated code: output=ae56bf7a28ca189a input=4c9720233d606604]*/
{
PyThreadState *ts = _PyThreadState_GET();
_PyThreadStateImpl *ts = (_PyThreadStateImpl *)_PyThreadState_GET();
if (loop == Py_None) {
loop = NULL;
}
Expand Down Expand Up @@ -3344,7 +3344,7 @@ _asyncio_get_running_loop_impl(PyObject *module)
/*[clinic end generated code: output=c247b5f9e529530e input=2a3bf02ba39f173d]*/
{
PyObject *loop;
PyThreadState *ts = _PyThreadState_GET();
_PyThreadStateImpl *ts = (_PyThreadStateImpl *)_PyThreadState_GET();
loop = Py_XNewRef(ts->asyncio_running_loop);
if (loop == NULL) {
/* There's no currently running event loop */
Expand Down

0 comments on commit d623558

Please sign in to comment.