Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Side by Side Diff: Modules/_asynciomodule.c

Issue 29271: Task.current_task(None) returns unexpected result
Patch Set: Created 3 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_asyncio/test_tasks.py ('k') | Modules/clinic/_asynciomodule.c.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Python.h" 1 #include "Python.h"
2 #include "structmember.h" 2 #include "structmember.h"
3 3
4 4
5 /*[clinic input] 5 /*[clinic input]
6 module _asyncio 6 module _asyncio
7 [clinic start generated code]*/ 7 [clinic start generated code]*/
8 /*[clinic end generated code: output=da39a3ee5e6b4b0d input=8fd17862aa989c69]*/ 8 /*[clinic end generated code: output=da39a3ee5e6b4b0d input=8fd17862aa989c69]*/
9 9
10 10
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 return task->task_fut_waiter; 1407 return task->task_fut_waiter;
1408 } 1408 }
1409 1409
1410 Py_RETURN_NONE; 1410 Py_RETURN_NONE;
1411 } 1411 }
1412 1412
1413 /*[clinic input] 1413 /*[clinic input]
1414 @classmethod 1414 @classmethod
1415 _asyncio.Task.current_task 1415 _asyncio.Task.current_task
1416 1416
1417 loop: 'O' = NULL 1417 loop: 'O' = None
1418 1418
1419 Return the currently running task in an event loop or None. 1419 Return the currently running task in an event loop or None.
1420 1420
1421 By default the current task for the current event loop is returned. 1421 By default the current task for the current event loop is returned.
1422 1422
1423 None is returned when called not in the context of a Task. 1423 None is returned when called not in the context of a Task.
1424 [clinic start generated code]*/ 1424 [clinic start generated code]*/
1425 1425
1426 static PyObject * 1426 static PyObject *
1427 _asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop) 1427 _asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop)
1428 /*[clinic end generated code: output=99fbe7332c516e03 input=cd784537f02cf833]*/ 1428 /*[clinic end generated code: output=99fbe7332c516e03 input=a0d6cdf2e3b243e1]*/
1429 { 1429 {
1430 PyObject *res; 1430 PyObject *res;
1431 1431
1432 if (loop == NULL) { 1432 if (loop == Py_None) {
1433 loop = _PyObject_CallNoArg(asyncio_get_event_loop); 1433 loop = _PyObject_CallNoArg(asyncio_get_event_loop);
1434 if (loop == NULL) { 1434 if (loop == NULL) {
1435 return NULL; 1435 return NULL;
1436 } 1436 }
1437 1437
1438 res = PyDict_GetItem(current_tasks, loop); 1438 res = PyDict_GetItem(current_tasks, loop);
1439 Py_DECREF(loop); 1439 Py_DECREF(loop);
1440 } 1440 }
1441 else { 1441 else {
1442 res = PyDict_GetItem(current_tasks, loop); 1442 res = PyDict_GetItem(current_tasks, loop);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 fail: 1494 fail:
1495 Py_XDECREF(set); 1495 Py_XDECREF(set);
1496 Py_XDECREF(iter); 1496 Py_XDECREF(iter);
1497 return NULL; 1497 return NULL;
1498 } 1498 }
1499 1499
1500 /*[clinic input] 1500 /*[clinic input]
1501 @classmethod 1501 @classmethod
1502 _asyncio.Task.all_tasks 1502 _asyncio.Task.all_tasks
1503 1503
1504 loop: 'O' = NULL 1504 loop: 'O' = None
1505 1505
1506 Return a set of all tasks for an event loop. 1506 Return a set of all tasks for an event loop.
1507 1507
1508 By default all tasks for the current event loop are returned. 1508 By default all tasks for the current event loop are returned.
1509 [clinic start generated code]*/ 1509 [clinic start generated code]*/
1510 1510
1511 static PyObject * 1511 static PyObject *
1512 _asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop) 1512 _asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop)
1513 /*[clinic end generated code: output=11f9b20749ccca5d input=cd64aa5f88bd5c49]*/ 1513 /*[clinic end generated code: output=11f9b20749ccca5d input=c6f5b53bd487488f]*/
1514 { 1514 {
1515 PyObject *res; 1515 PyObject *res;
1516 1516
1517 if (loop == NULL) { 1517 if (loop == Py_None) {
1518 loop = _PyObject_CallNoArg(asyncio_get_event_loop); 1518 loop = _PyObject_CallNoArg(asyncio_get_event_loop);
1519 if (loop == NULL) { 1519 if (loop == NULL) {
1520 return NULL; 1520 return NULL;
1521 } 1521 }
1522 1522
1523 res = task_all_tasks(loop); 1523 res = task_all_tasks(loop);
1524 Py_DECREF(loop); 1524 Py_DECREF(loop);
1525 } 1525 }
1526 else { 1526 else {
1527 res = task_all_tasks(loop); 1527 res = task_all_tasks(loop);
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 } 2461 }
2462 2462
2463 Py_INCREF(&TaskType); 2463 Py_INCREF(&TaskType);
2464 if (PyModule_AddObject(m, "Task", (PyObject *)&TaskType) < 0) { 2464 if (PyModule_AddObject(m, "Task", (PyObject *)&TaskType) < 0) {
2465 Py_DECREF(&TaskType); 2465 Py_DECREF(&TaskType);
2466 return NULL; 2466 return NULL;
2467 } 2467 }
2468 2468
2469 return m; 2469 return m;
2470 } 2470 }
OLDNEW
« no previous file with comments | « Lib/test/test_asyncio/test_tasks.py ('k') | Modules/clinic/_asynciomodule.c.h » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+