File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -413,12 +413,22 @@ future_ensure_alive(FutureObj *fut)
413413 } \
414414 } while(0);
415415
416+ static void unregister_task (asyncio_state * state , TaskObj * task );
416417
417418static int
418419future_schedule_callbacks (asyncio_state * state , FutureObj * fut )
419420{
420421 _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (fut );
421422
423+ assert (fut -> fut_state != STATE_PENDING );
424+
425+ if (Task_Check (state , fut )) {
426+ // remove task from linked-list of tasks
427+ // as it is finished now
428+ TaskObj * task = (TaskObj * )fut ;
429+ unregister_task (state , task );
430+ }
431+
422432 if (fut -> fut_callback0 != NULL ) {
423433 /* There's a 1st callback */
424434
@@ -4030,6 +4040,7 @@ add_tasks_llist(struct llist_node *head, PyListObject *tasks)
40304040 struct llist_node * node ;
40314041 llist_for_each_safe (node , head ) {
40324042 TaskObj * task = llist_data (node , TaskObj , task_node );
4043+ assert (task -> task_state == STATE_PENDING );
40334044 // The linked list holds borrowed references to task
40344045 // as such it is possible that the task is concurrently
40354046 // deallocated while added to this list.
You can’t perform that action at this time.
0 commit comments