Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
optimistic
  • Loading branch information
kumaraditya303 committed Feb 7, 2025
commit 6f3db4b017f293933fed822578bd9e8f12217a04
9 changes: 9 additions & 0 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,20 @@ future_ensure_alive(FutureObj *fut)
} \
} while(0);

static void unregister_task(asyncio_state *state, TaskObj *task);

static int
future_schedule_callbacks(asyncio_state *state, FutureObj *fut)
{
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(fut);

assert(fut->fut_state != STATE_PENDING);

if (Task_Check(state, fut)) {
TaskObj *task = (TaskObj *)fut;
unregister_task(state, task);
}

if (fut->fut_callback0 != NULL) {
/* There's a 1st callback */

Expand Down Expand Up @@ -4019,6 +4027,7 @@ add_tasks_llist(struct llist_node *head, PyListObject *tasks)
struct llist_node *node;
llist_for_each_safe(node, head) {
TaskObj *task = llist_data(node, TaskObj, task_node);
assert(task->task_state == STATE_PENDING);
// The linked list holds borrowed references to task
// as such it is possible that the task is concurrently
// deallocated while added to this list.
Expand Down