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