Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6f3db4b

Browse files
optimistic
1 parent a3d5aab commit 6f3db4b

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Modules/_asynciomodule.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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

417418
static int
418419
future_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.

0 commit comments

Comments
 (0)