Skip to content
Merged
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
Merge branch 'main' into asyncio-current-task-native-impl
  • Loading branch information
itamaro committed Dec 21, 2022
commit 637dfa7b3870850395e4f97b394a81db16e81a94
73 changes: 0 additions & 73 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3352,79 +3352,6 @@ _asyncio_current_task_impl(PyObject *module, PyObject *loop)
}


/*********************** PyRunningLoopHolder ********************/


static PyRunningLoopHolder *
new_running_loop_holder(asyncio_state *state, PyObject *loop)
{
PyRunningLoopHolder *rl = PyObject_GC_New(
PyRunningLoopHolder, state->PyRunningLoopHolder_Type);
if (rl == NULL) {
return NULL;
}

#if defined(HAVE_GETPID) && !defined(MS_WINDOWS)
rl->rl_pid = getpid();
#endif
rl->rl_loop = Py_NewRef(loop);

PyObject_GC_Track(rl);
return rl;
}


static int
PyRunningLoopHolder_clear(PyRunningLoopHolder *rl)
{
Py_CLEAR(rl->rl_loop);
return 0;
}


static int
PyRunningLoopHolder_traverse(PyRunningLoopHolder *rl, visitproc visit,
void *arg)
{
Py_VISIT(Py_TYPE(rl));
Py_VISIT(rl->rl_loop);
return 0;
}


static void
PyRunningLoopHolder_tp_dealloc(PyRunningLoopHolder *rl)
{
asyncio_state *state = get_asyncio_state_by_def((PyObject *)rl);
if (state->cached_running_holder == (PyObject *)rl) {
state->cached_running_holder = NULL;
}
PyTypeObject *tp = Py_TYPE(rl);
PyObject_GC_UnTrack(rl);
PyRunningLoopHolder_clear(rl);
PyObject_GC_Del(rl);
Py_DECREF(tp);
}


static PyType_Slot PyRunningLoopHolder_slots[] = {
{Py_tp_getattro, PyObject_GenericGetAttr},
{Py_tp_dealloc, (destructor)PyRunningLoopHolder_tp_dealloc},
{Py_tp_traverse, (traverseproc)PyRunningLoopHolder_traverse},
{Py_tp_clear, PyRunningLoopHolder_clear},
{0, NULL},
};


static PyType_Spec PyRunningLoopHolder_spec = {
.name = "_asyncio._RunningLoopHolder",
.basicsize = sizeof(PyRunningLoopHolder),
.slots = PyRunningLoopHolder_slots,
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_IMMUTABLETYPE),
};


/*********************** Module **************************/


Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.