File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -413,12 +413,20 @@ 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+ TaskObj * task = (TaskObj * )fut ;
427+ unregister_task (state , task );
428+ }
429+
422430 if (fut -> fut_callback0 != NULL ) {
423431 /* There's a 1st callback */
424432
@@ -4019,6 +4027,7 @@ add_tasks_llist(struct llist_node *head, PyListObject *tasks)
40194027 struct llist_node * node ;
40204028 llist_for_each_safe (node , head ) {
40214029 TaskObj * task = llist_data (node , TaskObj , task_node );
4030+ assert (task -> task_state == STATE_PENDING );
40224031 // The linked list holds borrowed references to task
40234032 // as such it is possible that the task is concurrently
40244033 // deallocated while added to this list.
You can’t perform that action at this time.
0 commit comments