diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2018-08-08 21:06:47 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2018-08-08 21:06:47 (GMT) |
commit | cca4eec3c0a67cbfeaf09182ea6c097a94891ff6 (patch) | |
tree | 0d04ad10797fa95e5e09f8b32e8aa9e0c50f6aac /Modules/clinic | |
parent | 52dee687af3671a31f63d6432de0d9ef370fd7b0 (diff) | |
download | cpython-cca4eec3c0a67cbfeaf09182ea6c097a94891ff6.zip cpython-cca4eec3c0a67cbfeaf09182ea6c097a94891ff6.tar.gz cpython-cca4eec3c0a67cbfeaf09182ea6c097a94891ff6.tar.bz2 |
bpo-34270: Make it possible to name asyncio tasks (GH-8547)
Co-authored-by: Antti Haapala <antti.haapala@anttipatterns.com>
Diffstat (limited to 'Modules/clinic')
-rw-r--r-- | Modules/clinic/_asynciomodule.c.h | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/Modules/clinic/_asynciomodule.c.h b/Modules/clinic/_asynciomodule.c.h index d8e1b6a..4f5326f 100644 --- a/Modules/clinic/_asynciomodule.c.h +++ b/Modules/clinic/_asynciomodule.c.h @@ -253,28 +253,30 @@ _asyncio_Future__repr_info(FutureObj *self, PyObject *Py_UNUSED(ignored)) } PyDoc_STRVAR(_asyncio_Task___init____doc__, -"Task(coro, *, loop=None)\n" +"Task(coro, *, loop=None, name=None)\n" "--\n" "\n" "A coroutine wrapped in a Future."); static int -_asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop); +_asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop, + PyObject *name); static int _asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs) { int return_value = -1; - static const char * const _keywords[] = {"coro", "loop", NULL}; - static _PyArg_Parser _parser = {"O|$O:Task", _keywords, 0}; + static const char * const _keywords[] = {"coro", "loop", "name", NULL}; + static _PyArg_Parser _parser = {"O|$OO:Task", _keywords, 0}; PyObject *coro; PyObject *loop = Py_None; + PyObject *name = Py_None; if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, - &coro, &loop)) { + &coro, &loop, &name)) { goto exit; } - return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop); + return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop, name); exit: return return_value; @@ -500,6 +502,31 @@ PyDoc_STRVAR(_asyncio_Task_set_exception__doc__, #define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \ {"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__}, +PyDoc_STRVAR(_asyncio_Task_get_name__doc__, +"get_name($self, /)\n" +"--\n" +"\n"); + +#define _ASYNCIO_TASK_GET_NAME_METHODDEF \ + {"get_name", (PyCFunction)_asyncio_Task_get_name, METH_NOARGS, _asyncio_Task_get_name__doc__}, + +static PyObject * +_asyncio_Task_get_name_impl(TaskObj *self); + +static PyObject * +_asyncio_Task_get_name(TaskObj *self, PyObject *Py_UNUSED(ignored)) +{ + return _asyncio_Task_get_name_impl(self); +} + +PyDoc_STRVAR(_asyncio_Task_set_name__doc__, +"set_name($self, value, /)\n" +"--\n" +"\n"); + +#define _ASYNCIO_TASK_SET_NAME_METHODDEF \ + {"set_name", (PyCFunction)_asyncio_Task_set_name, METH_O, _asyncio_Task_set_name__doc__}, + PyDoc_STRVAR(_asyncio__get_running_loop__doc__, "_get_running_loop($module, /)\n" "--\n" @@ -711,4 +738,4 @@ _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=b6148b0134e7a819 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=67da879c9f841505 input=a9049054013a1b77]*/ |