File tree 1 file changed +11
-0
lines changed
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)
413
413
} \
414
414
} while(0);
415
415
416
+ static void unregister_task (asyncio_state * state , TaskObj * task );
416
417
417
418
static int
418
419
future_schedule_callbacks (asyncio_state * state , FutureObj * fut )
419
420
{
420
421
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (fut );
421
422
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
+
422
432
if (fut -> fut_callback0 != NULL ) {
423
433
/* There's a 1st callback */
424
434
@@ -4030,6 +4040,7 @@ add_tasks_llist(struct llist_node *head, PyListObject *tasks)
4030
4040
struct llist_node * node ;
4031
4041
llist_for_each_safe (node , head ) {
4032
4042
TaskObj * task = llist_data (node , TaskObj , task_node );
4043
+ assert (task -> task_state == STATE_PENDING );
4033
4044
// The linked list holds borrowed references to task
4034
4045
// as such it is possible that the task is concurrently
4035
4046
// deallocated while added to this list.
You can’t perform that action at this time.
0 commit comments