Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
GH-107803: double linked list implementation for asyncio tasks#107804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
cc66eebd5a3d87a0c5fcf77d012f5d9653d5a001984cdc83435a00f1fddb9d61d32835b46bcfeee7ead2af0280a999fff787a223118124083cb567395526365c5b55982cf69b8998f6ad93c4e135726d98dd0492832530280b65e0b67649e1252b2f457739a4670731e061081836d254efce4b3c7b604c56beb04File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1953,6 +1953,9 @@ register_task(asyncio_state *state, TaskObj *task) | ||
| { | ||
| assert(Task_Check(state, task)); | ||
kumaraditya303 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| assert(task != &state->asyncio_tasks.tail); | ||
| if (task->prev != NULL) { | ||
| return; | ||
| } | ||
| assert(task->prev == NULL); | ||
kumaraditya303 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| assert(task->next == NULL); | ||
| assert(state->asyncio_tasks.head != NULL); | ||
| @@ -1973,7 +1976,11 @@ unregister_task(asyncio_state *state, TaskObj *task) | ||
| { | ||
| assert(Task_Check(state, task)); | ||
| assert(task != &state->asyncio_tasks.tail); | ||
| if (task->prev == NULL) { | ||
| assert(task->next == NULL); | ||
| assert(state->asyncio_tasks.head != task); | ||
| return; | ||
| } | ||
| task->prev->next = task->next; | ||
| if (task->next == NULL) { | ||
| assert(state->asyncio_tasks.head == task); | ||
| @@ -1983,6 +1990,7 @@ unregister_task(asyncio_state *state, TaskObj *task) | ||
| } | ||
| task->next = NULL; | ||
| task->prev = NULL; | ||
| assert(state->asyncio_tasks.head != task); | ||
| } | ||
| static int | ||
| @@ -3583,21 +3591,32 @@ _asyncio_all_tasks_impl(PyObject *module, PyObject *loop) | ||
| if (tasks == NULL) { | ||
| return NULL; | ||
| } | ||
| if (loop == Py_None) { | ||
| loop = _asyncio_get_running_loop_impl(module); | ||
| if (loop == NULL) { | ||
| Py_DECREF(tasks); | ||
| return NULL; | ||
| } | ||
| } else { | ||
| Py_INCREF(loop); | ||
kumaraditya303 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
| asyncio_state *state = get_asyncio_state(module); | ||
| TaskObj *head = state->asyncio_tasks.head; | ||
| assert(head != NULL); | ||
| assert(head->next == NULL); | ||
| TaskObj *tail = &state->asyncio_tasks.tail; | ||
| while (head != tail) | ||
| { | ||
| if (head->task_loop == loop) { | ||
| if (PySet_Add(tasks, (PyObject *)head) < 0) { | ||
| Py_DECREF(tasks); | ||
| Py_DECREF(loop); | ||
| return NULL; | ||
| } | ||
| } | ||
| head = head->prev; | ||
kumaraditya303 marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
| Py_DECREF(loop); | ||
| return tasks; | ||
| } | ||