@@ -220,7 +220,7 @@ static PyObject * future_new_iter(PyObject *);
220220
221221static PyObject *
222222task_step_handle_result_impl (asyncio_state * state , TaskObj * task , PyObject * result );
223-
223+ static void unregister_task ( TaskObj * task );
224224
225225static void
226226clear_task_coro (TaskObj * task )
@@ -413,7 +413,6 @@ future_ensure_alive(FutureObj *fut)
413413 } \
414414 } while(0);
415415
416- static void unregister_task (asyncio_state * state , TaskObj * task );
417416
418417static int
419418future_schedule_callbacks (asyncio_state * state , FutureObj * fut )
@@ -426,7 +425,7 @@ future_schedule_callbacks(asyncio_state *state, FutureObj *fut)
426425 // remove task from linked-list of tasks
427426 // as it is finished now
428427 TaskObj * task = (TaskObj * )fut ;
429- unregister_task (state , task );
428+ unregister_task (task );
430429 }
431430
432431 if (fut -> fut_callback0 != NULL ) {
@@ -2175,9 +2174,8 @@ static PyMethodDef TaskWakeupDef = {
21752174/* ----- Task introspection helpers */
21762175
21772176static void
2178- register_task (asyncio_state * state , TaskObj * task )
2177+ register_task (TaskObj * task )
21792178{
2180- assert (Task_Check (state , task ));
21812179 if (task -> task_node .next != NULL ) {
21822180 // already registered
21832181 assert (task -> task_node .prev != NULL );
@@ -2206,9 +2204,8 @@ unregister_task_safe(TaskObj *task)
22062204}
22072205
22082206static void
2209- unregister_task (asyncio_state * state , TaskObj * task )
2207+ unregister_task (TaskObj * task )
22102208{
2211- assert (Task_Check (state , task ));
22122209#ifdef Py_GIL_DISABLED
22132210 // check if we are in the same thread
22142211 // if so, we can avoid locking
@@ -2490,7 +2487,7 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop,
24902487 // works correctly in non-owning threads.
24912488 _PyObject_SetMaybeWeakref ((PyObject * )self );
24922489#endif
2493- register_task (state , self );
2490+ register_task (self );
24942491 return 0 ;
24952492}
24962493
@@ -3075,8 +3072,7 @@ TaskObj_dealloc(PyObject *self)
30753072 _PyObject_ResurrectStart (self );
30763073 // Unregister the task here so that even if any subclass of Task
30773074 // which doesn't end up calling TaskObj_finalize not crashes.
3078- asyncio_state * state = get_asyncio_state_by_def (self );
3079- unregister_task (state , task );
3075+ unregister_task (task );
30803076
30813077 PyObject_CallFinalizer (self );
30823078
@@ -3613,7 +3609,7 @@ task_eager_start(asyncio_state *state, TaskObj *task)
36133609 }
36143610
36153611 if (task -> task_state == STATE_PENDING ) {
3616- register_task (state , task );
3612+ register_task (task );
36173613 } else {
36183614 // This seems to really help performance on pyperformance benchmarks
36193615 clear_task_coro (task );
@@ -3804,7 +3800,7 @@ _asyncio__register_task_impl(PyObject *module, PyObject *task)
38043800 if (Task_Check (state , task )) {
38053801 // task is an asyncio.Task instance or subclass, use efficient
38063802 // linked-list implementation.
3807- register_task (state , (TaskObj * )task );
3803+ register_task ((TaskObj * )task );
38083804 Py_RETURN_NONE ;
38093805 }
38103806 // As task does not inherit from asyncio.Task, fallback to less efficient
@@ -3856,7 +3852,7 @@ _asyncio__unregister_task_impl(PyObject *module, PyObject *task)
38563852{
38573853 asyncio_state * state = get_asyncio_state (module );
38583854 if (Task_Check (state , task )) {
3859- unregister_task (state , (TaskObj * )task );
3855+ unregister_task ((TaskObj * )task );
38603856 Py_RETURN_NONE ;
38613857 }
38623858 PyObject * res = PyObject_CallMethodOneArg (state -> non_asyncio_tasks ,
0 commit comments