static PyObject *
task_step_handle_result_impl(asyncio_state *state, TaskObj *task, PyObject *result);
-
+static void unregister_task(TaskObj *task);
static void
clear_task_coro(TaskObj *task)
} \
} while(0);
-static void unregister_task(asyncio_state *state, TaskObj *task);
static int
future_schedule_callbacks(asyncio_state *state, FutureObj *fut)
// remove task from linked-list of tasks
// as it is finished now
TaskObj *task = (TaskObj *)fut;
- unregister_task(state, task);
+ unregister_task(task);
}
if (fut->fut_callback0 != NULL) {
/* ----- Task introspection helpers */
static void
-register_task(asyncio_state *state, TaskObj *task)
+register_task(TaskObj *task)
{
- assert(Task_Check(state, task));
if (task->task_node.next != NULL) {
// already registered
assert(task->task_node.prev != NULL);
}
static void
-unregister_task(asyncio_state *state, TaskObj *task)
+unregister_task(TaskObj *task)
{
- assert(Task_Check(state, task));
#ifdef Py_GIL_DISABLED
// check if we are in the same thread
// if so, we can avoid locking
// works correctly in non-owning threads.
_PyObject_SetMaybeWeakref((PyObject *)self);
#endif
- register_task(state, self);
+ register_task(self);
return 0;
}
_PyObject_ResurrectStart(self);
// Unregister the task here so that even if any subclass of Task
// which doesn't end up calling TaskObj_finalize not crashes.
- asyncio_state *state = get_asyncio_state_by_def(self);
- unregister_task(state, task);
+ unregister_task(task);
PyObject_CallFinalizer(self);
}
if (task->task_state == STATE_PENDING) {
- register_task(state, task);
+ register_task(task);
} else {
// This seems to really help performance on pyperformance benchmarks
clear_task_coro(task);
if (Task_Check(state, task)) {
// task is an asyncio.Task instance or subclass, use efficient
// linked-list implementation.
- register_task(state, (TaskObj *)task);
+ register_task((TaskObj *)task);
Py_RETURN_NONE;
}
// As task does not inherit from asyncio.Task, fallback to less efficient
{
asyncio_state *state = get_asyncio_state(module);
if (Task_Check(state, task)) {
- unregister_task(state, (TaskObj *)task);
+ unregister_task((TaskObj *)task);
Py_RETURN_NONE;
}
PyObject *res = PyObject_CallMethodOneArg(state->non_asyncio_tasks,