Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(_asyncio_Future___init____doc__, |
| 6 | "Future(*, loop=None)\n" |
| 7 | "--\n" |
| 8 | "\n" |
| 9 | "This class is *almost* compatible with concurrent.futures.Future.\n" |
| 10 | "\n" |
| 11 | " Differences:\n" |
| 12 | "\n" |
| 13 | " - result() and exception() do not take a timeout argument and\n" |
| 14 | " raise an exception when the future isn\'t done yet.\n" |
| 15 | "\n" |
| 16 | " - Callbacks registered with add_done_callback() are always called\n" |
| 17 | " via the event loop\'s call_soon_threadsafe().\n" |
| 18 | "\n" |
| 19 | " - This class is not compatible with the wait() and as_completed()\n" |
| 20 | " methods in the concurrent.futures package."); |
| 21 | |
| 22 | static int |
| 23 | _asyncio_Future___init___impl(FutureObj *self, PyObject *loop); |
| 24 | |
| 25 | static int |
| 26 | _asyncio_Future___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 27 | { |
| 28 | int return_value = -1; |
| 29 | static const char * const _keywords[] = {"loop", NULL}; |
| 30 | static _PyArg_Parser _parser = {"|$O:Future", _keywords, 0}; |
Serhiy Storchaka | bca4939 | 2017-09-03 08:10:14 +0300 | [diff] [blame] | 31 | PyObject *loop = Py_None; |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 32 | |
| 33 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 34 | &loop)) { |
| 35 | goto exit; |
| 36 | } |
| 37 | return_value = _asyncio_Future___init___impl((FutureObj *)self, loop); |
| 38 | |
| 39 | exit: |
| 40 | return return_value; |
| 41 | } |
| 42 | |
| 43 | PyDoc_STRVAR(_asyncio_Future_result__doc__, |
| 44 | "result($self, /)\n" |
| 45 | "--\n" |
| 46 | "\n" |
| 47 | "Return the result this future represents.\n" |
| 48 | "\n" |
| 49 | "If the future has been cancelled, raises CancelledError. If the\n" |
| 50 | "future\'s result isn\'t yet available, raises InvalidStateError. If\n" |
| 51 | "the future is done and has an exception set, this exception is raised."); |
| 52 | |
| 53 | #define _ASYNCIO_FUTURE_RESULT_METHODDEF \ |
| 54 | {"result", (PyCFunction)_asyncio_Future_result, METH_NOARGS, _asyncio_Future_result__doc__}, |
| 55 | |
| 56 | static PyObject * |
| 57 | _asyncio_Future_result_impl(FutureObj *self); |
| 58 | |
| 59 | static PyObject * |
| 60 | _asyncio_Future_result(FutureObj *self, PyObject *Py_UNUSED(ignored)) |
| 61 | { |
| 62 | return _asyncio_Future_result_impl(self); |
| 63 | } |
| 64 | |
| 65 | PyDoc_STRVAR(_asyncio_Future_exception__doc__, |
| 66 | "exception($self, /)\n" |
| 67 | "--\n" |
| 68 | "\n" |
| 69 | "Return the exception that was set on this future.\n" |
| 70 | "\n" |
| 71 | "The exception (or None if no exception was set) is returned only if\n" |
| 72 | "the future is done. If the future has been cancelled, raises\n" |
| 73 | "CancelledError. If the future isn\'t done yet, raises\n" |
| 74 | "InvalidStateError."); |
| 75 | |
| 76 | #define _ASYNCIO_FUTURE_EXCEPTION_METHODDEF \ |
| 77 | {"exception", (PyCFunction)_asyncio_Future_exception, METH_NOARGS, _asyncio_Future_exception__doc__}, |
| 78 | |
| 79 | static PyObject * |
| 80 | _asyncio_Future_exception_impl(FutureObj *self); |
| 81 | |
| 82 | static PyObject * |
| 83 | _asyncio_Future_exception(FutureObj *self, PyObject *Py_UNUSED(ignored)) |
| 84 | { |
| 85 | return _asyncio_Future_exception_impl(self); |
| 86 | } |
| 87 | |
| 88 | PyDoc_STRVAR(_asyncio_Future_set_result__doc__, |
Yury Selivanov | 0cf16f9 | 2017-12-25 10:48:15 -0500 | [diff] [blame] | 89 | "set_result($self, result, /)\n" |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 90 | "--\n" |
| 91 | "\n" |
| 92 | "Mark the future done and set its result.\n" |
| 93 | "\n" |
| 94 | "If the future is already done when this method is called, raises\n" |
| 95 | "InvalidStateError."); |
| 96 | |
| 97 | #define _ASYNCIO_FUTURE_SET_RESULT_METHODDEF \ |
| 98 | {"set_result", (PyCFunction)_asyncio_Future_set_result, METH_O, _asyncio_Future_set_result__doc__}, |
| 99 | |
| 100 | PyDoc_STRVAR(_asyncio_Future_set_exception__doc__, |
| 101 | "set_exception($self, exception, /)\n" |
| 102 | "--\n" |
| 103 | "\n" |
| 104 | "Mark the future done and set an exception.\n" |
| 105 | "\n" |
| 106 | "If the future is already done when this method is called, raises\n" |
| 107 | "InvalidStateError."); |
| 108 | |
| 109 | #define _ASYNCIO_FUTURE_SET_EXCEPTION_METHODDEF \ |
| 110 | {"set_exception", (PyCFunction)_asyncio_Future_set_exception, METH_O, _asyncio_Future_set_exception__doc__}, |
| 111 | |
| 112 | PyDoc_STRVAR(_asyncio_Future_add_done_callback__doc__, |
| 113 | "add_done_callback($self, fn, /)\n" |
| 114 | "--\n" |
| 115 | "\n" |
| 116 | "Add a callback to be run when the future becomes done.\n" |
| 117 | "\n" |
| 118 | "The callback is called with a single argument - the future object. If\n" |
| 119 | "the future is already done when this is called, the callback is\n" |
| 120 | "scheduled with call_soon."); |
| 121 | |
| 122 | #define _ASYNCIO_FUTURE_ADD_DONE_CALLBACK_METHODDEF \ |
| 123 | {"add_done_callback", (PyCFunction)_asyncio_Future_add_done_callback, METH_O, _asyncio_Future_add_done_callback__doc__}, |
| 124 | |
| 125 | PyDoc_STRVAR(_asyncio_Future_remove_done_callback__doc__, |
| 126 | "remove_done_callback($self, fn, /)\n" |
| 127 | "--\n" |
| 128 | "\n" |
| 129 | "Remove all instances of a callback from the \"call when done\" list.\n" |
| 130 | "\n" |
| 131 | "Returns the number of callbacks removed."); |
| 132 | |
| 133 | #define _ASYNCIO_FUTURE_REMOVE_DONE_CALLBACK_METHODDEF \ |
| 134 | {"remove_done_callback", (PyCFunction)_asyncio_Future_remove_done_callback, METH_O, _asyncio_Future_remove_done_callback__doc__}, |
| 135 | |
| 136 | PyDoc_STRVAR(_asyncio_Future_cancel__doc__, |
| 137 | "cancel($self, /)\n" |
| 138 | "--\n" |
| 139 | "\n" |
| 140 | "Cancel the future and schedule callbacks.\n" |
| 141 | "\n" |
| 142 | "If the future is already done or cancelled, return False. Otherwise,\n" |
| 143 | "change the future\'s state to cancelled, schedule the callbacks and\n" |
| 144 | "return True."); |
| 145 | |
| 146 | #define _ASYNCIO_FUTURE_CANCEL_METHODDEF \ |
| 147 | {"cancel", (PyCFunction)_asyncio_Future_cancel, METH_NOARGS, _asyncio_Future_cancel__doc__}, |
| 148 | |
| 149 | static PyObject * |
| 150 | _asyncio_Future_cancel_impl(FutureObj *self); |
| 151 | |
| 152 | static PyObject * |
| 153 | _asyncio_Future_cancel(FutureObj *self, PyObject *Py_UNUSED(ignored)) |
| 154 | { |
| 155 | return _asyncio_Future_cancel_impl(self); |
| 156 | } |
| 157 | |
| 158 | PyDoc_STRVAR(_asyncio_Future_cancelled__doc__, |
| 159 | "cancelled($self, /)\n" |
| 160 | "--\n" |
| 161 | "\n" |
| 162 | "Return True if the future was cancelled."); |
| 163 | |
| 164 | #define _ASYNCIO_FUTURE_CANCELLED_METHODDEF \ |
| 165 | {"cancelled", (PyCFunction)_asyncio_Future_cancelled, METH_NOARGS, _asyncio_Future_cancelled__doc__}, |
| 166 | |
| 167 | static PyObject * |
| 168 | _asyncio_Future_cancelled_impl(FutureObj *self); |
| 169 | |
| 170 | static PyObject * |
| 171 | _asyncio_Future_cancelled(FutureObj *self, PyObject *Py_UNUSED(ignored)) |
| 172 | { |
| 173 | return _asyncio_Future_cancelled_impl(self); |
| 174 | } |
| 175 | |
| 176 | PyDoc_STRVAR(_asyncio_Future_done__doc__, |
| 177 | "done($self, /)\n" |
| 178 | "--\n" |
| 179 | "\n" |
| 180 | "Return True if the future is done.\n" |
| 181 | "\n" |
| 182 | "Done means either that a result / exception are available, or that the\n" |
| 183 | "future was cancelled."); |
| 184 | |
| 185 | #define _ASYNCIO_FUTURE_DONE_METHODDEF \ |
| 186 | {"done", (PyCFunction)_asyncio_Future_done, METH_NOARGS, _asyncio_Future_done__doc__}, |
| 187 | |
| 188 | static PyObject * |
| 189 | _asyncio_Future_done_impl(FutureObj *self); |
| 190 | |
| 191 | static PyObject * |
| 192 | _asyncio_Future_done(FutureObj *self, PyObject *Py_UNUSED(ignored)) |
| 193 | { |
| 194 | return _asyncio_Future_done_impl(self); |
| 195 | } |
| 196 | |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 197 | PyDoc_STRVAR(_asyncio_Future_get_loop__doc__, |
| 198 | "get_loop($self, /)\n" |
| 199 | "--\n" |
| 200 | "\n" |
| 201 | "Return the event loop the Future is bound to."); |
| 202 | |
| 203 | #define _ASYNCIO_FUTURE_GET_LOOP_METHODDEF \ |
| 204 | {"get_loop", (PyCFunction)_asyncio_Future_get_loop, METH_NOARGS, _asyncio_Future_get_loop__doc__}, |
| 205 | |
| 206 | static PyObject * |
| 207 | _asyncio_Future_get_loop_impl(FutureObj *self); |
| 208 | |
| 209 | static PyObject * |
| 210 | _asyncio_Future_get_loop(FutureObj *self, PyObject *Py_UNUSED(ignored)) |
| 211 | { |
| 212 | return _asyncio_Future_get_loop_impl(self); |
| 213 | } |
| 214 | |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 215 | PyDoc_STRVAR(_asyncio_Future__repr_info__doc__, |
| 216 | "_repr_info($self, /)\n" |
| 217 | "--\n" |
| 218 | "\n"); |
| 219 | |
| 220 | #define _ASYNCIO_FUTURE__REPR_INFO_METHODDEF \ |
| 221 | {"_repr_info", (PyCFunction)_asyncio_Future__repr_info, METH_NOARGS, _asyncio_Future__repr_info__doc__}, |
| 222 | |
| 223 | static PyObject * |
| 224 | _asyncio_Future__repr_info_impl(FutureObj *self); |
| 225 | |
| 226 | static PyObject * |
| 227 | _asyncio_Future__repr_info(FutureObj *self, PyObject *Py_UNUSED(ignored)) |
| 228 | { |
| 229 | return _asyncio_Future__repr_info_impl(self); |
| 230 | } |
| 231 | |
| 232 | PyDoc_STRVAR(_asyncio_Future__schedule_callbacks__doc__, |
| 233 | "_schedule_callbacks($self, /)\n" |
| 234 | "--\n" |
| 235 | "\n"); |
| 236 | |
| 237 | #define _ASYNCIO_FUTURE__SCHEDULE_CALLBACKS_METHODDEF \ |
| 238 | {"_schedule_callbacks", (PyCFunction)_asyncio_Future__schedule_callbacks, METH_NOARGS, _asyncio_Future__schedule_callbacks__doc__}, |
| 239 | |
| 240 | static PyObject * |
| 241 | _asyncio_Future__schedule_callbacks_impl(FutureObj *self); |
| 242 | |
| 243 | static PyObject * |
| 244 | _asyncio_Future__schedule_callbacks(FutureObj *self, PyObject *Py_UNUSED(ignored)) |
| 245 | { |
| 246 | return _asyncio_Future__schedule_callbacks_impl(self); |
| 247 | } |
| 248 | |
| 249 | PyDoc_STRVAR(_asyncio_Task___init____doc__, |
| 250 | "Task(coro, *, loop=None)\n" |
| 251 | "--\n" |
| 252 | "\n" |
| 253 | "A coroutine wrapped in a Future."); |
| 254 | |
| 255 | static int |
| 256 | _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop); |
| 257 | |
| 258 | static int |
| 259 | _asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 260 | { |
| 261 | int return_value = -1; |
| 262 | static const char * const _keywords[] = {"coro", "loop", NULL}; |
| 263 | static _PyArg_Parser _parser = {"O|$O:Task", _keywords, 0}; |
| 264 | PyObject *coro; |
Serhiy Storchaka | bca4939 | 2017-09-03 08:10:14 +0300 | [diff] [blame] | 265 | PyObject *loop = Py_None; |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 266 | |
| 267 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 268 | &coro, &loop)) { |
| 269 | goto exit; |
| 270 | } |
| 271 | return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop); |
| 272 | |
| 273 | exit: |
| 274 | return return_value; |
| 275 | } |
| 276 | |
| 277 | PyDoc_STRVAR(_asyncio_Task_current_task__doc__, |
| 278 | "current_task($type, /, loop=None)\n" |
| 279 | "--\n" |
| 280 | "\n" |
| 281 | "Return the currently running task in an event loop or None.\n" |
| 282 | "\n" |
| 283 | "By default the current task for the current event loop is returned.\n" |
| 284 | "\n" |
| 285 | "None is returned when called not in the context of a Task."); |
| 286 | |
| 287 | #define _ASYNCIO_TASK_CURRENT_TASK_METHODDEF \ |
Serhiy Storchaka | 6969eaf | 2017-07-03 21:20:15 +0300 | [diff] [blame] | 288 | {"current_task", (PyCFunction)_asyncio_Task_current_task, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, _asyncio_Task_current_task__doc__}, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 289 | |
| 290 | static PyObject * |
| 291 | _asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop); |
| 292 | |
| 293 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 294 | _asyncio_Task_current_task(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 295 | { |
| 296 | PyObject *return_value = NULL; |
| 297 | static const char * const _keywords[] = {"loop", NULL}; |
| 298 | static _PyArg_Parser _parser = {"|O:current_task", _keywords, 0}; |
Yury Selivanov | 8d26aa9 | 2017-03-02 22:16:33 -0500 | [diff] [blame] | 299 | PyObject *loop = Py_None; |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 300 | |
Victor Stinner | 3e1fad6 | 2017-01-17 01:29:01 +0100 | [diff] [blame] | 301 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 302 | &loop)) { |
| 303 | goto exit; |
| 304 | } |
| 305 | return_value = _asyncio_Task_current_task_impl(type, loop); |
| 306 | |
| 307 | exit: |
| 308 | return return_value; |
| 309 | } |
| 310 | |
| 311 | PyDoc_STRVAR(_asyncio_Task_all_tasks__doc__, |
| 312 | "all_tasks($type, /, loop=None)\n" |
| 313 | "--\n" |
| 314 | "\n" |
| 315 | "Return a set of all tasks for an event loop.\n" |
| 316 | "\n" |
| 317 | "By default all tasks for the current event loop are returned."); |
| 318 | |
| 319 | #define _ASYNCIO_TASK_ALL_TASKS_METHODDEF \ |
Serhiy Storchaka | 6969eaf | 2017-07-03 21:20:15 +0300 | [diff] [blame] | 320 | {"all_tasks", (PyCFunction)_asyncio_Task_all_tasks, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, _asyncio_Task_all_tasks__doc__}, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 321 | |
| 322 | static PyObject * |
| 323 | _asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop); |
| 324 | |
| 325 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 326 | _asyncio_Task_all_tasks(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 327 | { |
| 328 | PyObject *return_value = NULL; |
| 329 | static const char * const _keywords[] = {"loop", NULL}; |
| 330 | static _PyArg_Parser _parser = {"|O:all_tasks", _keywords, 0}; |
Yury Selivanov | 8d26aa9 | 2017-03-02 22:16:33 -0500 | [diff] [blame] | 331 | PyObject *loop = Py_None; |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 332 | |
Victor Stinner | 3e1fad6 | 2017-01-17 01:29:01 +0100 | [diff] [blame] | 333 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 334 | &loop)) { |
| 335 | goto exit; |
| 336 | } |
| 337 | return_value = _asyncio_Task_all_tasks_impl(type, loop); |
| 338 | |
| 339 | exit: |
| 340 | return return_value; |
| 341 | } |
| 342 | |
| 343 | PyDoc_STRVAR(_asyncio_Task__repr_info__doc__, |
| 344 | "_repr_info($self, /)\n" |
| 345 | "--\n" |
| 346 | "\n"); |
| 347 | |
| 348 | #define _ASYNCIO_TASK__REPR_INFO_METHODDEF \ |
| 349 | {"_repr_info", (PyCFunction)_asyncio_Task__repr_info, METH_NOARGS, _asyncio_Task__repr_info__doc__}, |
| 350 | |
| 351 | static PyObject * |
| 352 | _asyncio_Task__repr_info_impl(TaskObj *self); |
| 353 | |
| 354 | static PyObject * |
| 355 | _asyncio_Task__repr_info(TaskObj *self, PyObject *Py_UNUSED(ignored)) |
| 356 | { |
| 357 | return _asyncio_Task__repr_info_impl(self); |
| 358 | } |
| 359 | |
| 360 | PyDoc_STRVAR(_asyncio_Task_cancel__doc__, |
| 361 | "cancel($self, /)\n" |
| 362 | "--\n" |
| 363 | "\n" |
| 364 | "Request that this task cancel itself.\n" |
| 365 | "\n" |
| 366 | "This arranges for a CancelledError to be thrown into the\n" |
| 367 | "wrapped coroutine on the next cycle through the event loop.\n" |
| 368 | "The coroutine then has a chance to clean up or even deny\n" |
| 369 | "the request using try/except/finally.\n" |
| 370 | "\n" |
| 371 | "Unlike Future.cancel, this does not guarantee that the\n" |
| 372 | "task will be cancelled: the exception might be caught and\n" |
| 373 | "acted upon, delaying cancellation of the task or preventing\n" |
| 374 | "cancellation completely. The task may also return a value or\n" |
| 375 | "raise a different exception.\n" |
| 376 | "\n" |
| 377 | "Immediately after this method is called, Task.cancelled() will\n" |
| 378 | "not return True (unless the task was already cancelled). A\n" |
| 379 | "task will be marked as cancelled when the wrapped coroutine\n" |
| 380 | "terminates with a CancelledError exception (even if cancel()\n" |
| 381 | "was not called)."); |
| 382 | |
| 383 | #define _ASYNCIO_TASK_CANCEL_METHODDEF \ |
| 384 | {"cancel", (PyCFunction)_asyncio_Task_cancel, METH_NOARGS, _asyncio_Task_cancel__doc__}, |
| 385 | |
| 386 | static PyObject * |
| 387 | _asyncio_Task_cancel_impl(TaskObj *self); |
| 388 | |
| 389 | static PyObject * |
| 390 | _asyncio_Task_cancel(TaskObj *self, PyObject *Py_UNUSED(ignored)) |
| 391 | { |
| 392 | return _asyncio_Task_cancel_impl(self); |
| 393 | } |
| 394 | |
| 395 | PyDoc_STRVAR(_asyncio_Task_get_stack__doc__, |
| 396 | "get_stack($self, /, *, limit=None)\n" |
| 397 | "--\n" |
| 398 | "\n" |
| 399 | "Return the list of stack frames for this task\'s coroutine.\n" |
| 400 | "\n" |
| 401 | "If the coroutine is not done, this returns the stack where it is\n" |
| 402 | "suspended. If the coroutine has completed successfully or was\n" |
| 403 | "cancelled, this returns an empty list. If the coroutine was\n" |
| 404 | "terminated by an exception, this returns the list of traceback\n" |
| 405 | "frames.\n" |
| 406 | "\n" |
| 407 | "The frames are always ordered from oldest to newest.\n" |
| 408 | "\n" |
| 409 | "The optional limit gives the maximum number of frames to\n" |
| 410 | "return; by default all available frames are returned. Its\n" |
| 411 | "meaning differs depending on whether a stack or a traceback is\n" |
| 412 | "returned: the newest frames of a stack are returned, but the\n" |
| 413 | "oldest frames of a traceback are returned. (This matches the\n" |
| 414 | "behavior of the traceback module.)\n" |
| 415 | "\n" |
| 416 | "For reasons beyond our control, only one stack frame is\n" |
| 417 | "returned for a suspended coroutine."); |
| 418 | |
| 419 | #define _ASYNCIO_TASK_GET_STACK_METHODDEF \ |
Serhiy Storchaka | 6969eaf | 2017-07-03 21:20:15 +0300 | [diff] [blame] | 420 | {"get_stack", (PyCFunction)_asyncio_Task_get_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__}, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 421 | |
| 422 | static PyObject * |
| 423 | _asyncio_Task_get_stack_impl(TaskObj *self, PyObject *limit); |
| 424 | |
| 425 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 426 | _asyncio_Task_get_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 427 | { |
| 428 | PyObject *return_value = NULL; |
| 429 | static const char * const _keywords[] = {"limit", NULL}; |
| 430 | static _PyArg_Parser _parser = {"|$O:get_stack", _keywords, 0}; |
| 431 | PyObject *limit = Py_None; |
| 432 | |
Victor Stinner | 3e1fad6 | 2017-01-17 01:29:01 +0100 | [diff] [blame] | 433 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 434 | &limit)) { |
| 435 | goto exit; |
| 436 | } |
| 437 | return_value = _asyncio_Task_get_stack_impl(self, limit); |
| 438 | |
| 439 | exit: |
| 440 | return return_value; |
| 441 | } |
| 442 | |
| 443 | PyDoc_STRVAR(_asyncio_Task_print_stack__doc__, |
| 444 | "print_stack($self, /, *, limit=None, file=None)\n" |
| 445 | "--\n" |
| 446 | "\n" |
| 447 | "Print the stack or traceback for this task\'s coroutine.\n" |
| 448 | "\n" |
| 449 | "This produces output similar to that of the traceback module,\n" |
| 450 | "for the frames retrieved by get_stack(). The limit argument\n" |
| 451 | "is passed to get_stack(). The file argument is an I/O stream\n" |
| 452 | "to which the output is written; by default output is written\n" |
| 453 | "to sys.stderr."); |
| 454 | |
| 455 | #define _ASYNCIO_TASK_PRINT_STACK_METHODDEF \ |
Serhiy Storchaka | 6969eaf | 2017-07-03 21:20:15 +0300 | [diff] [blame] | 456 | {"print_stack", (PyCFunction)_asyncio_Task_print_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__}, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 457 | |
| 458 | static PyObject * |
| 459 | _asyncio_Task_print_stack_impl(TaskObj *self, PyObject *limit, |
| 460 | PyObject *file); |
| 461 | |
| 462 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 463 | _asyncio_Task_print_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 464 | { |
| 465 | PyObject *return_value = NULL; |
| 466 | static const char * const _keywords[] = {"limit", "file", NULL}; |
| 467 | static _PyArg_Parser _parser = {"|$OO:print_stack", _keywords, 0}; |
| 468 | PyObject *limit = Py_None; |
| 469 | PyObject *file = Py_None; |
| 470 | |
Victor Stinner | 3e1fad6 | 2017-01-17 01:29:01 +0100 | [diff] [blame] | 471 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 472 | &limit, &file)) { |
| 473 | goto exit; |
| 474 | } |
| 475 | return_value = _asyncio_Task_print_stack_impl(self, limit, file); |
| 476 | |
| 477 | exit: |
| 478 | return return_value; |
| 479 | } |
| 480 | |
| 481 | PyDoc_STRVAR(_asyncio_Task__step__doc__, |
| 482 | "_step($self, /, exc=None)\n" |
| 483 | "--\n" |
| 484 | "\n"); |
| 485 | |
| 486 | #define _ASYNCIO_TASK__STEP_METHODDEF \ |
Serhiy Storchaka | 6969eaf | 2017-07-03 21:20:15 +0300 | [diff] [blame] | 487 | {"_step", (PyCFunction)_asyncio_Task__step, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task__step__doc__}, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 488 | |
| 489 | static PyObject * |
| 490 | _asyncio_Task__step_impl(TaskObj *self, PyObject *exc); |
| 491 | |
| 492 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 493 | _asyncio_Task__step(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 494 | { |
| 495 | PyObject *return_value = NULL; |
| 496 | static const char * const _keywords[] = {"exc", NULL}; |
| 497 | static _PyArg_Parser _parser = {"|O:_step", _keywords, 0}; |
Serhiy Storchaka | bca4939 | 2017-09-03 08:10:14 +0300 | [diff] [blame] | 498 | PyObject *exc = Py_None; |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 499 | |
Victor Stinner | 3e1fad6 | 2017-01-17 01:29:01 +0100 | [diff] [blame] | 500 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 501 | &exc)) { |
| 502 | goto exit; |
| 503 | } |
| 504 | return_value = _asyncio_Task__step_impl(self, exc); |
| 505 | |
| 506 | exit: |
| 507 | return return_value; |
| 508 | } |
| 509 | |
| 510 | PyDoc_STRVAR(_asyncio_Task__wakeup__doc__, |
| 511 | "_wakeup($self, /, fut)\n" |
| 512 | "--\n" |
| 513 | "\n"); |
| 514 | |
| 515 | #define _ASYNCIO_TASK__WAKEUP_METHODDEF \ |
Serhiy Storchaka | 6969eaf | 2017-07-03 21:20:15 +0300 | [diff] [blame] | 516 | {"_wakeup", (PyCFunction)_asyncio_Task__wakeup, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task__wakeup__doc__}, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 517 | |
| 518 | static PyObject * |
| 519 | _asyncio_Task__wakeup_impl(TaskObj *self, PyObject *fut); |
| 520 | |
| 521 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 522 | _asyncio_Task__wakeup(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 523 | { |
| 524 | PyObject *return_value = NULL; |
| 525 | static const char * const _keywords[] = {"fut", NULL}; |
| 526 | static _PyArg_Parser _parser = {"O:_wakeup", _keywords, 0}; |
| 527 | PyObject *fut; |
| 528 | |
Victor Stinner | 3e1fad6 | 2017-01-17 01:29:01 +0100 | [diff] [blame] | 529 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
Yury Selivanov | a0c1ba6 | 2016-10-28 12:52:37 -0400 | [diff] [blame] | 530 | &fut)) { |
| 531 | goto exit; |
| 532 | } |
| 533 | return_value = _asyncio_Task__wakeup_impl(self, fut); |
| 534 | |
| 535 | exit: |
| 536 | return return_value; |
| 537 | } |
Yury Selivanov | a70232f | 2017-12-13 14:49:42 -0500 | [diff] [blame] | 538 | |
Yury Selivanov | 0cf16f9 | 2017-12-25 10:48:15 -0500 | [diff] [blame] | 539 | PyDoc_STRVAR(_asyncio_Task_set_result__doc__, |
| 540 | "set_result($self, result, /)\n" |
| 541 | "--\n" |
| 542 | "\n"); |
| 543 | |
| 544 | #define _ASYNCIO_TASK_SET_RESULT_METHODDEF \ |
| 545 | {"set_result", (PyCFunction)_asyncio_Task_set_result, METH_O, _asyncio_Task_set_result__doc__}, |
| 546 | |
| 547 | PyDoc_STRVAR(_asyncio_Task_set_exception__doc__, |
| 548 | "set_exception($self, exception, /)\n" |
| 549 | "--\n" |
| 550 | "\n"); |
| 551 | |
| 552 | #define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \ |
| 553 | {"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__}, |
| 554 | |
Yury Selivanov | a70232f | 2017-12-13 14:49:42 -0500 | [diff] [blame] | 555 | PyDoc_STRVAR(_asyncio__get_running_loop__doc__, |
| 556 | "_get_running_loop($module, /)\n" |
| 557 | "--\n" |
| 558 | "\n" |
| 559 | "Return the running event loop or None.\n" |
| 560 | "\n" |
| 561 | "This is a low-level function intended to be used by event loops.\n" |
| 562 | "This function is thread-specific."); |
| 563 | |
| 564 | #define _ASYNCIO__GET_RUNNING_LOOP_METHODDEF \ |
| 565 | {"_get_running_loop", (PyCFunction)_asyncio__get_running_loop, METH_NOARGS, _asyncio__get_running_loop__doc__}, |
| 566 | |
| 567 | static PyObject * |
| 568 | _asyncio__get_running_loop_impl(PyObject *module); |
| 569 | |
| 570 | static PyObject * |
| 571 | _asyncio__get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 572 | { |
| 573 | return _asyncio__get_running_loop_impl(module); |
| 574 | } |
| 575 | |
| 576 | PyDoc_STRVAR(_asyncio__set_running_loop__doc__, |
| 577 | "_set_running_loop($module, loop, /)\n" |
| 578 | "--\n" |
| 579 | "\n" |
| 580 | "Set the running event loop.\n" |
| 581 | "\n" |
| 582 | "This is a low-level function intended to be used by event loops.\n" |
| 583 | "This function is thread-specific."); |
| 584 | |
| 585 | #define _ASYNCIO__SET_RUNNING_LOOP_METHODDEF \ |
| 586 | {"_set_running_loop", (PyCFunction)_asyncio__set_running_loop, METH_O, _asyncio__set_running_loop__doc__}, |
| 587 | |
| 588 | PyDoc_STRVAR(_asyncio_get_event_loop__doc__, |
| 589 | "get_event_loop($module, /)\n" |
| 590 | "--\n" |
| 591 | "\n" |
| 592 | "Return an asyncio event loop.\n" |
| 593 | "\n" |
| 594 | "When called from a coroutine or a callback (e.g. scheduled with\n" |
| 595 | "call_soon or similar API), this function will always return the\n" |
| 596 | "running event loop.\n" |
| 597 | "\n" |
| 598 | "If there is no running event loop set, the function will return\n" |
| 599 | "the result of `get_event_loop_policy().get_event_loop()` call."); |
| 600 | |
| 601 | #define _ASYNCIO_GET_EVENT_LOOP_METHODDEF \ |
| 602 | {"get_event_loop", (PyCFunction)_asyncio_get_event_loop, METH_NOARGS, _asyncio_get_event_loop__doc__}, |
| 603 | |
| 604 | static PyObject * |
| 605 | _asyncio_get_event_loop_impl(PyObject *module); |
| 606 | |
| 607 | static PyObject * |
| 608 | _asyncio_get_event_loop(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 609 | { |
| 610 | return _asyncio_get_event_loop_impl(module); |
| 611 | } |
| 612 | |
| 613 | PyDoc_STRVAR(_asyncio_get_running_loop__doc__, |
| 614 | "get_running_loop($module, /)\n" |
| 615 | "--\n" |
| 616 | "\n" |
| 617 | "Return the running event loop. Raise a RuntimeError if there is none.\n" |
| 618 | "\n" |
| 619 | "This function is thread-specific."); |
| 620 | |
| 621 | #define _ASYNCIO_GET_RUNNING_LOOP_METHODDEF \ |
| 622 | {"get_running_loop", (PyCFunction)_asyncio_get_running_loop, METH_NOARGS, _asyncio_get_running_loop__doc__}, |
| 623 | |
| 624 | static PyObject * |
| 625 | _asyncio_get_running_loop_impl(PyObject *module); |
| 626 | |
| 627 | static PyObject * |
| 628 | _asyncio_get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 629 | { |
| 630 | return _asyncio_get_running_loop_impl(module); |
| 631 | } |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 632 | |
| 633 | PyDoc_STRVAR(_asyncio__register_task__doc__, |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 634 | "_register_task($module, /, task)\n" |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 635 | "--\n" |
| 636 | "\n" |
| 637 | "Register a new task in asyncio as executed by loop.\n" |
| 638 | "\n" |
| 639 | "Returns None."); |
| 640 | |
| 641 | #define _ASYNCIO__REGISTER_TASK_METHODDEF \ |
| 642 | {"_register_task", (PyCFunction)_asyncio__register_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__}, |
| 643 | |
| 644 | static PyObject * |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 645 | _asyncio__register_task_impl(PyObject *module, PyObject *task); |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 646 | |
| 647 | static PyObject * |
| 648 | _asyncio__register_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 649 | { |
| 650 | PyObject *return_value = NULL; |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 651 | static const char * const _keywords[] = {"task", NULL}; |
| 652 | static _PyArg_Parser _parser = {"O:_register_task", _keywords, 0}; |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 653 | PyObject *task; |
| 654 | |
| 655 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 656 | &task)) { |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 657 | goto exit; |
| 658 | } |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 659 | return_value = _asyncio__register_task_impl(module, task); |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 660 | |
| 661 | exit: |
| 662 | return return_value; |
| 663 | } |
| 664 | |
| 665 | PyDoc_STRVAR(_asyncio__unregister_task__doc__, |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 666 | "_unregister_task($module, /, task)\n" |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 667 | "--\n" |
| 668 | "\n" |
| 669 | "Unregister a task.\n" |
| 670 | "\n" |
| 671 | "Returns None."); |
| 672 | |
| 673 | #define _ASYNCIO__UNREGISTER_TASK_METHODDEF \ |
| 674 | {"_unregister_task", (PyCFunction)_asyncio__unregister_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__}, |
| 675 | |
| 676 | static PyObject * |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 677 | _asyncio__unregister_task_impl(PyObject *module, PyObject *task); |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 678 | |
| 679 | static PyObject * |
| 680 | _asyncio__unregister_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 681 | { |
| 682 | PyObject *return_value = NULL; |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 683 | static const char * const _keywords[] = {"task", NULL}; |
| 684 | static _PyArg_Parser _parser = {"O:_unregister_task", _keywords, 0}; |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 685 | PyObject *task; |
| 686 | |
| 687 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 688 | &task)) { |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 689 | goto exit; |
| 690 | } |
Yury Selivanov | ca9b36c | 2017-12-23 15:04:15 -0500 | [diff] [blame] | 691 | return_value = _asyncio__unregister_task_impl(module, task); |
Andrew Svetlov | 44d1a59 | 2017-12-16 21:58:38 +0200 | [diff] [blame] | 692 | |
| 693 | exit: |
| 694 | return return_value; |
| 695 | } |
| 696 | |
| 697 | PyDoc_STRVAR(_asyncio__enter_task__doc__, |
| 698 | "_enter_task($module, /, loop, task)\n" |
| 699 | "--\n" |
| 700 | "\n" |
| 701 | "Enter into task execution or resume suspended task.\n" |
| 702 | "\n" |
| 703 | "Task belongs to loop.\n" |
| 704 | "\n" |
| 705 | "Returns None."); |
| 706 | |
| 707 | #define _ASYNCIO__ENTER_TASK_METHODDEF \ |
| 708 | {"_enter_task", (PyCFunction)_asyncio__enter_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__}, |
| 709 | |
| 710 | static PyObject * |
| 711 | _asyncio__enter_task_impl(PyObject *module, PyObject *loop, PyObject *task); |
| 712 | |
| 713 | static PyObject * |
| 714 | _asyncio__enter_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 715 | { |
| 716 | PyObject *return_value = NULL; |
| 717 | static const char * const _keywords[] = {"loop", "task", NULL}; |
| 718 | static _PyArg_Parser _parser = {"OO:_enter_task", _keywords, 0}; |
| 719 | PyObject *loop; |
| 720 | PyObject *task; |
| 721 | |
| 722 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
| 723 | &loop, &task)) { |
| 724 | goto exit; |
| 725 | } |
| 726 | return_value = _asyncio__enter_task_impl(module, loop, task); |
| 727 | |
| 728 | exit: |
| 729 | return return_value; |
| 730 | } |
| 731 | |
| 732 | PyDoc_STRVAR(_asyncio__leave_task__doc__, |
| 733 | "_leave_task($module, /, loop, task)\n" |
| 734 | "--\n" |
| 735 | "\n" |
| 736 | "Leave task execution or suspend a task.\n" |
| 737 | "\n" |
| 738 | "Task belongs to loop.\n" |
| 739 | "\n" |
| 740 | "Returns None."); |
| 741 | |
| 742 | #define _ASYNCIO__LEAVE_TASK_METHODDEF \ |
| 743 | {"_leave_task", (PyCFunction)_asyncio__leave_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__}, |
| 744 | |
| 745 | static PyObject * |
| 746 | _asyncio__leave_task_impl(PyObject *module, PyObject *loop, PyObject *task); |
| 747 | |
| 748 | static PyObject * |
| 749 | _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 750 | { |
| 751 | PyObject *return_value = NULL; |
| 752 | static const char * const _keywords[] = {"loop", "task", NULL}; |
| 753 | static _PyArg_Parser _parser = {"OO:_leave_task", _keywords, 0}; |
| 754 | PyObject *loop; |
| 755 | PyObject *task; |
| 756 | |
| 757 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
| 758 | &loop, &task)) { |
| 759 | goto exit; |
| 760 | } |
| 761 | return_value = _asyncio__leave_task_impl(module, loop, task); |
| 762 | |
| 763 | exit: |
| 764 | return return_value; |
| 765 | } |
Yury Selivanov | 0cf16f9 | 2017-12-25 10:48:15 -0500 | [diff] [blame] | 766 | /*[clinic end generated code: output=616e814431893dcc input=a9049054013a1b77]*/ |