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_CAST(_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, /, msg=None)\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_CAST(_asyncio_Future_cancel), METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_cancel__doc__},
188
189 static PyObject *
190 _asyncio_Future_cancel_impl(FutureObj *self, PyObject *msg);
191
192 static PyObject *
_asyncio_Future_cancel(FutureObj * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)193 _asyncio_Future_cancel(FutureObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
194 {
195 PyObject *return_value = NULL;
196 static const char * const _keywords[] = {"msg", NULL};
197 static _PyArg_Parser _parser = {NULL, _keywords, "cancel", 0};
198 PyObject *argsbuf[1];
199 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
200 PyObject *msg = Py_None;
201
202 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
203 if (!args) {
204 goto exit;
205 }
206 if (!noptargs) {
207 goto skip_optional_pos;
208 }
209 msg = args[0];
210 skip_optional_pos:
211 return_value = _asyncio_Future_cancel_impl(self, msg);
212
213 exit:
214 return return_value;
215 }
216
217 PyDoc_STRVAR(_asyncio_Future_cancelled__doc__,
218 "cancelled($self, /)\n"
219 "--\n"
220 "\n"
221 "Return True if the future was cancelled.");
222
223 #define _ASYNCIO_FUTURE_CANCELLED_METHODDEF \
224 {"cancelled", (PyCFunction)_asyncio_Future_cancelled, METH_NOARGS, _asyncio_Future_cancelled__doc__},
225
226 static PyObject *
227 _asyncio_Future_cancelled_impl(FutureObj *self);
228
229 static PyObject *
_asyncio_Future_cancelled(FutureObj * self,PyObject * Py_UNUSED (ignored))230 _asyncio_Future_cancelled(FutureObj *self, PyObject *Py_UNUSED(ignored))
231 {
232 return _asyncio_Future_cancelled_impl(self);
233 }
234
235 PyDoc_STRVAR(_asyncio_Future_done__doc__,
236 "done($self, /)\n"
237 "--\n"
238 "\n"
239 "Return True if the future is done.\n"
240 "\n"
241 "Done means either that a result / exception are available, or that the\n"
242 "future was cancelled.");
243
244 #define _ASYNCIO_FUTURE_DONE_METHODDEF \
245 {"done", (PyCFunction)_asyncio_Future_done, METH_NOARGS, _asyncio_Future_done__doc__},
246
247 static PyObject *
248 _asyncio_Future_done_impl(FutureObj *self);
249
250 static PyObject *
_asyncio_Future_done(FutureObj * self,PyObject * Py_UNUSED (ignored))251 _asyncio_Future_done(FutureObj *self, PyObject *Py_UNUSED(ignored))
252 {
253 return _asyncio_Future_done_impl(self);
254 }
255
256 PyDoc_STRVAR(_asyncio_Future_get_loop__doc__,
257 "get_loop($self, /)\n"
258 "--\n"
259 "\n"
260 "Return the event loop the Future is bound to.");
261
262 #define _ASYNCIO_FUTURE_GET_LOOP_METHODDEF \
263 {"get_loop", (PyCFunction)_asyncio_Future_get_loop, METH_NOARGS, _asyncio_Future_get_loop__doc__},
264
265 static PyObject *
266 _asyncio_Future_get_loop_impl(FutureObj *self);
267
268 static PyObject *
_asyncio_Future_get_loop(FutureObj * self,PyObject * Py_UNUSED (ignored))269 _asyncio_Future_get_loop(FutureObj *self, PyObject *Py_UNUSED(ignored))
270 {
271 return _asyncio_Future_get_loop_impl(self);
272 }
273
274 PyDoc_STRVAR(_asyncio_Future__make_cancelled_error__doc__,
275 "_make_cancelled_error($self, /)\n"
276 "--\n"
277 "\n"
278 "Create the CancelledError to raise if the Future is cancelled.\n"
279 "\n"
280 "This should only be called once when handling a cancellation since\n"
281 "it erases the context exception value.");
282
283 #define _ASYNCIO_FUTURE__MAKE_CANCELLED_ERROR_METHODDEF \
284 {"_make_cancelled_error", (PyCFunction)_asyncio_Future__make_cancelled_error, METH_NOARGS, _asyncio_Future__make_cancelled_error__doc__},
285
286 static PyObject *
287 _asyncio_Future__make_cancelled_error_impl(FutureObj *self);
288
289 static PyObject *
_asyncio_Future__make_cancelled_error(FutureObj * self,PyObject * Py_UNUSED (ignored))290 _asyncio_Future__make_cancelled_error(FutureObj *self, PyObject *Py_UNUSED(ignored))
291 {
292 return _asyncio_Future__make_cancelled_error_impl(self);
293 }
294
295 PyDoc_STRVAR(_asyncio_Task___init____doc__,
296 "Task(coro, *, loop=None, name=None, context=None)\n"
297 "--\n"
298 "\n"
299 "A coroutine wrapped in a Future.");
300
301 static int
302 _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop,
303 PyObject *name, PyObject *context);
304
305 static int
_asyncio_Task___init__(PyObject * self,PyObject * args,PyObject * kwargs)306 _asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs)
307 {
308 int return_value = -1;
309 static const char * const _keywords[] = {"coro", "loop", "name", "context", NULL};
310 static _PyArg_Parser _parser = {NULL, _keywords, "Task", 0};
311 PyObject *argsbuf[4];
312 PyObject * const *fastargs;
313 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
314 Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
315 PyObject *coro;
316 PyObject *loop = Py_None;
317 PyObject *name = Py_None;
318 PyObject *context = Py_None;
319
320 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf);
321 if (!fastargs) {
322 goto exit;
323 }
324 coro = fastargs[0];
325 if (!noptargs) {
326 goto skip_optional_kwonly;
327 }
328 if (fastargs[1]) {
329 loop = fastargs[1];
330 if (!--noptargs) {
331 goto skip_optional_kwonly;
332 }
333 }
334 if (fastargs[2]) {
335 name = fastargs[2];
336 if (!--noptargs) {
337 goto skip_optional_kwonly;
338 }
339 }
340 context = fastargs[3];
341 skip_optional_kwonly:
342 return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop, name, context);
343
344 exit:
345 return return_value;
346 }
347
348 PyDoc_STRVAR(_asyncio_Task__make_cancelled_error__doc__,
349 "_make_cancelled_error($self, /)\n"
350 "--\n"
351 "\n"
352 "Create the CancelledError to raise if the Task is cancelled.\n"
353 "\n"
354 "This should only be called once when handling a cancellation since\n"
355 "it erases the context exception value.");
356
357 #define _ASYNCIO_TASK__MAKE_CANCELLED_ERROR_METHODDEF \
358 {"_make_cancelled_error", (PyCFunction)_asyncio_Task__make_cancelled_error, METH_NOARGS, _asyncio_Task__make_cancelled_error__doc__},
359
360 static PyObject *
361 _asyncio_Task__make_cancelled_error_impl(TaskObj *self);
362
363 static PyObject *
_asyncio_Task__make_cancelled_error(TaskObj * self,PyObject * Py_UNUSED (ignored))364 _asyncio_Task__make_cancelled_error(TaskObj *self, PyObject *Py_UNUSED(ignored))
365 {
366 return _asyncio_Task__make_cancelled_error_impl(self);
367 }
368
369 PyDoc_STRVAR(_asyncio_Task_cancel__doc__,
370 "cancel($self, /, msg=None)\n"
371 "--\n"
372 "\n"
373 "Request that this task cancel itself.\n"
374 "\n"
375 "This arranges for a CancelledError to be thrown into the\n"
376 "wrapped coroutine on the next cycle through the event loop.\n"
377 "The coroutine then has a chance to clean up or even deny\n"
378 "the request using try/except/finally.\n"
379 "\n"
380 "Unlike Future.cancel, this does not guarantee that the\n"
381 "task will be cancelled: the exception might be caught and\n"
382 "acted upon, delaying cancellation of the task or preventing\n"
383 "cancellation completely. The task may also return a value or\n"
384 "raise a different exception.\n"
385 "\n"
386 "Immediately after this method is called, Task.cancelled() will\n"
387 "not return True (unless the task was already cancelled). A\n"
388 "task will be marked as cancelled when the wrapped coroutine\n"
389 "terminates with a CancelledError exception (even if cancel()\n"
390 "was not called).\n"
391 "\n"
392 "This also increases the task\'s count of cancellation requests.");
393
394 #define _ASYNCIO_TASK_CANCEL_METHODDEF \
395 {"cancel", _PyCFunction_CAST(_asyncio_Task_cancel), METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_cancel__doc__},
396
397 static PyObject *
398 _asyncio_Task_cancel_impl(TaskObj *self, PyObject *msg);
399
400 static PyObject *
_asyncio_Task_cancel(TaskObj * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)401 _asyncio_Task_cancel(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
402 {
403 PyObject *return_value = NULL;
404 static const char * const _keywords[] = {"msg", NULL};
405 static _PyArg_Parser _parser = {NULL, _keywords, "cancel", 0};
406 PyObject *argsbuf[1];
407 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
408 PyObject *msg = Py_None;
409
410 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
411 if (!args) {
412 goto exit;
413 }
414 if (!noptargs) {
415 goto skip_optional_pos;
416 }
417 msg = args[0];
418 skip_optional_pos:
419 return_value = _asyncio_Task_cancel_impl(self, msg);
420
421 exit:
422 return return_value;
423 }
424
425 PyDoc_STRVAR(_asyncio_Task_cancelling__doc__,
426 "cancelling($self, /)\n"
427 "--\n"
428 "\n"
429 "Return the count of the task\'s cancellation requests.\n"
430 "\n"
431 "This count is incremented when .cancel() is called\n"
432 "and may be decremented using .uncancel().");
433
434 #define _ASYNCIO_TASK_CANCELLING_METHODDEF \
435 {"cancelling", (PyCFunction)_asyncio_Task_cancelling, METH_NOARGS, _asyncio_Task_cancelling__doc__},
436
437 static PyObject *
438 _asyncio_Task_cancelling_impl(TaskObj *self);
439
440 static PyObject *
_asyncio_Task_cancelling(TaskObj * self,PyObject * Py_UNUSED (ignored))441 _asyncio_Task_cancelling(TaskObj *self, PyObject *Py_UNUSED(ignored))
442 {
443 return _asyncio_Task_cancelling_impl(self);
444 }
445
446 PyDoc_STRVAR(_asyncio_Task_uncancel__doc__,
447 "uncancel($self, /)\n"
448 "--\n"
449 "\n"
450 "Decrement the task\'s count of cancellation requests.\n"
451 "\n"
452 "This should be used by tasks that catch CancelledError\n"
453 "and wish to continue indefinitely until they are cancelled again.\n"
454 "\n"
455 "Returns the remaining number of cancellation requests.");
456
457 #define _ASYNCIO_TASK_UNCANCEL_METHODDEF \
458 {"uncancel", (PyCFunction)_asyncio_Task_uncancel, METH_NOARGS, _asyncio_Task_uncancel__doc__},
459
460 static PyObject *
461 _asyncio_Task_uncancel_impl(TaskObj *self);
462
463 static PyObject *
_asyncio_Task_uncancel(TaskObj * self,PyObject * Py_UNUSED (ignored))464 _asyncio_Task_uncancel(TaskObj *self, PyObject *Py_UNUSED(ignored))
465 {
466 return _asyncio_Task_uncancel_impl(self);
467 }
468
469 PyDoc_STRVAR(_asyncio_Task_get_stack__doc__,
470 "get_stack($self, /, *, limit=None)\n"
471 "--\n"
472 "\n"
473 "Return the list of stack frames for this task\'s coroutine.\n"
474 "\n"
475 "If the coroutine is not done, this returns the stack where it is\n"
476 "suspended. If the coroutine has completed successfully or was\n"
477 "cancelled, this returns an empty list. If the coroutine was\n"
478 "terminated by an exception, this returns the list of traceback\n"
479 "frames.\n"
480 "\n"
481 "The frames are always ordered from oldest to newest.\n"
482 "\n"
483 "The optional limit gives the maximum number of frames to\n"
484 "return; by default all available frames are returned. Its\n"
485 "meaning differs depending on whether a stack or a traceback is\n"
486 "returned: the newest frames of a stack are returned, but the\n"
487 "oldest frames of a traceback are returned. (This matches the\n"
488 "behavior of the traceback module.)\n"
489 "\n"
490 "For reasons beyond our control, only one stack frame is\n"
491 "returned for a suspended coroutine.");
492
493 #define _ASYNCIO_TASK_GET_STACK_METHODDEF \
494 {"get_stack", _PyCFunction_CAST(_asyncio_Task_get_stack), METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__},
495
496 static PyObject *
497 _asyncio_Task_get_stack_impl(TaskObj *self, PyObject *limit);
498
499 static PyObject *
_asyncio_Task_get_stack(TaskObj * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)500 _asyncio_Task_get_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
501 {
502 PyObject *return_value = NULL;
503 static const char * const _keywords[] = {"limit", NULL};
504 static _PyArg_Parser _parser = {NULL, _keywords, "get_stack", 0};
505 PyObject *argsbuf[1];
506 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
507 PyObject *limit = Py_None;
508
509 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
510 if (!args) {
511 goto exit;
512 }
513 if (!noptargs) {
514 goto skip_optional_kwonly;
515 }
516 limit = args[0];
517 skip_optional_kwonly:
518 return_value = _asyncio_Task_get_stack_impl(self, limit);
519
520 exit:
521 return return_value;
522 }
523
524 PyDoc_STRVAR(_asyncio_Task_print_stack__doc__,
525 "print_stack($self, /, *, limit=None, file=None)\n"
526 "--\n"
527 "\n"
528 "Print the stack or traceback for this task\'s coroutine.\n"
529 "\n"
530 "This produces output similar to that of the traceback module,\n"
531 "for the frames retrieved by get_stack(). The limit argument\n"
532 "is passed to get_stack(). The file argument is an I/O stream\n"
533 "to which the output is written; by default output is written\n"
534 "to sys.stderr.");
535
536 #define _ASYNCIO_TASK_PRINT_STACK_METHODDEF \
537 {"print_stack", _PyCFunction_CAST(_asyncio_Task_print_stack), METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__},
538
539 static PyObject *
540 _asyncio_Task_print_stack_impl(TaskObj *self, PyObject *limit,
541 PyObject *file);
542
543 static PyObject *
_asyncio_Task_print_stack(TaskObj * self,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)544 _asyncio_Task_print_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
545 {
546 PyObject *return_value = NULL;
547 static const char * const _keywords[] = {"limit", "file", NULL};
548 static _PyArg_Parser _parser = {NULL, _keywords, "print_stack", 0};
549 PyObject *argsbuf[2];
550 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
551 PyObject *limit = Py_None;
552 PyObject *file = Py_None;
553
554 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
555 if (!args) {
556 goto exit;
557 }
558 if (!noptargs) {
559 goto skip_optional_kwonly;
560 }
561 if (args[0]) {
562 limit = args[0];
563 if (!--noptargs) {
564 goto skip_optional_kwonly;
565 }
566 }
567 file = args[1];
568 skip_optional_kwonly:
569 return_value = _asyncio_Task_print_stack_impl(self, limit, file);
570
571 exit:
572 return return_value;
573 }
574
575 PyDoc_STRVAR(_asyncio_Task_set_result__doc__,
576 "set_result($self, result, /)\n"
577 "--\n"
578 "\n");
579
580 #define _ASYNCIO_TASK_SET_RESULT_METHODDEF \
581 {"set_result", (PyCFunction)_asyncio_Task_set_result, METH_O, _asyncio_Task_set_result__doc__},
582
583 PyDoc_STRVAR(_asyncio_Task_set_exception__doc__,
584 "set_exception($self, exception, /)\n"
585 "--\n"
586 "\n");
587
588 #define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \
589 {"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__},
590
591 PyDoc_STRVAR(_asyncio_Task_get_coro__doc__,
592 "get_coro($self, /)\n"
593 "--\n"
594 "\n");
595
596 #define _ASYNCIO_TASK_GET_CORO_METHODDEF \
597 {"get_coro", (PyCFunction)_asyncio_Task_get_coro, METH_NOARGS, _asyncio_Task_get_coro__doc__},
598
599 static PyObject *
600 _asyncio_Task_get_coro_impl(TaskObj *self);
601
602 static PyObject *
_asyncio_Task_get_coro(TaskObj * self,PyObject * Py_UNUSED (ignored))603 _asyncio_Task_get_coro(TaskObj *self, PyObject *Py_UNUSED(ignored))
604 {
605 return _asyncio_Task_get_coro_impl(self);
606 }
607
608 PyDoc_STRVAR(_asyncio_Task_get_name__doc__,
609 "get_name($self, /)\n"
610 "--\n"
611 "\n");
612
613 #define _ASYNCIO_TASK_GET_NAME_METHODDEF \
614 {"get_name", (PyCFunction)_asyncio_Task_get_name, METH_NOARGS, _asyncio_Task_get_name__doc__},
615
616 static PyObject *
617 _asyncio_Task_get_name_impl(TaskObj *self);
618
619 static PyObject *
_asyncio_Task_get_name(TaskObj * self,PyObject * Py_UNUSED (ignored))620 _asyncio_Task_get_name(TaskObj *self, PyObject *Py_UNUSED(ignored))
621 {
622 return _asyncio_Task_get_name_impl(self);
623 }
624
625 PyDoc_STRVAR(_asyncio_Task_set_name__doc__,
626 "set_name($self, value, /)\n"
627 "--\n"
628 "\n");
629
630 #define _ASYNCIO_TASK_SET_NAME_METHODDEF \
631 {"set_name", (PyCFunction)_asyncio_Task_set_name, METH_O, _asyncio_Task_set_name__doc__},
632
633 PyDoc_STRVAR(_asyncio__get_running_loop__doc__,
634 "_get_running_loop($module, /)\n"
635 "--\n"
636 "\n"
637 "Return the running event loop or None.\n"
638 "\n"
639 "This is a low-level function intended to be used by event loops.\n"
640 "This function is thread-specific.");
641
642 #define _ASYNCIO__GET_RUNNING_LOOP_METHODDEF \
643 {"_get_running_loop", (PyCFunction)_asyncio__get_running_loop, METH_NOARGS, _asyncio__get_running_loop__doc__},
644
645 static PyObject *
646 _asyncio__get_running_loop_impl(PyObject *module);
647
648 static PyObject *
_asyncio__get_running_loop(PyObject * module,PyObject * Py_UNUSED (ignored))649 _asyncio__get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
650 {
651 return _asyncio__get_running_loop_impl(module);
652 }
653
654 PyDoc_STRVAR(_asyncio__set_running_loop__doc__,
655 "_set_running_loop($module, loop, /)\n"
656 "--\n"
657 "\n"
658 "Set the running event loop.\n"
659 "\n"
660 "This is a low-level function intended to be used by event loops.\n"
661 "This function is thread-specific.");
662
663 #define _ASYNCIO__SET_RUNNING_LOOP_METHODDEF \
664 {"_set_running_loop", (PyCFunction)_asyncio__set_running_loop, METH_O, _asyncio__set_running_loop__doc__},
665
666 PyDoc_STRVAR(_asyncio_get_event_loop__doc__,
667 "get_event_loop($module, /)\n"
668 "--\n"
669 "\n"
670 "Return an asyncio event loop.\n"
671 "\n"
672 "When called from a coroutine or a callback (e.g. scheduled with\n"
673 "call_soon or similar API), this function will always return the\n"
674 "running event loop.\n"
675 "\n"
676 "If there is no running event loop set, the function will return\n"
677 "the result of `get_event_loop_policy().get_event_loop()` call.");
678
679 #define _ASYNCIO_GET_EVENT_LOOP_METHODDEF \
680 {"get_event_loop", (PyCFunction)_asyncio_get_event_loop, METH_NOARGS, _asyncio_get_event_loop__doc__},
681
682 static PyObject *
683 _asyncio_get_event_loop_impl(PyObject *module);
684
685 static PyObject *
_asyncio_get_event_loop(PyObject * module,PyObject * Py_UNUSED (ignored))686 _asyncio_get_event_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
687 {
688 return _asyncio_get_event_loop_impl(module);
689 }
690
691 PyDoc_STRVAR(_asyncio__get_event_loop__doc__,
692 "_get_event_loop($module, /, stacklevel=3)\n"
693 "--\n"
694 "\n");
695
696 #define _ASYNCIO__GET_EVENT_LOOP_METHODDEF \
697 {"_get_event_loop", _PyCFunction_CAST(_asyncio__get_event_loop), METH_FASTCALL|METH_KEYWORDS, _asyncio__get_event_loop__doc__},
698
699 static PyObject *
700 _asyncio__get_event_loop_impl(PyObject *module, int stacklevel);
701
702 static PyObject *
_asyncio__get_event_loop(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)703 _asyncio__get_event_loop(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
704 {
705 PyObject *return_value = NULL;
706 static const char * const _keywords[] = {"stacklevel", NULL};
707 static _PyArg_Parser _parser = {NULL, _keywords, "_get_event_loop", 0};
708 PyObject *argsbuf[1];
709 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
710 int stacklevel = 3;
711
712 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
713 if (!args) {
714 goto exit;
715 }
716 if (!noptargs) {
717 goto skip_optional_pos;
718 }
719 stacklevel = _PyLong_AsInt(args[0]);
720 if (stacklevel == -1 && PyErr_Occurred()) {
721 goto exit;
722 }
723 skip_optional_pos:
724 return_value = _asyncio__get_event_loop_impl(module, stacklevel);
725
726 exit:
727 return return_value;
728 }
729
730 PyDoc_STRVAR(_asyncio_get_running_loop__doc__,
731 "get_running_loop($module, /)\n"
732 "--\n"
733 "\n"
734 "Return the running event loop. Raise a RuntimeError if there is none.\n"
735 "\n"
736 "This function is thread-specific.");
737
738 #define _ASYNCIO_GET_RUNNING_LOOP_METHODDEF \
739 {"get_running_loop", (PyCFunction)_asyncio_get_running_loop, METH_NOARGS, _asyncio_get_running_loop__doc__},
740
741 static PyObject *
742 _asyncio_get_running_loop_impl(PyObject *module);
743
744 static PyObject *
_asyncio_get_running_loop(PyObject * module,PyObject * Py_UNUSED (ignored))745 _asyncio_get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
746 {
747 return _asyncio_get_running_loop_impl(module);
748 }
749
750 PyDoc_STRVAR(_asyncio__register_task__doc__,
751 "_register_task($module, /, task)\n"
752 "--\n"
753 "\n"
754 "Register a new task in asyncio as executed by loop.\n"
755 "\n"
756 "Returns None.");
757
758 #define _ASYNCIO__REGISTER_TASK_METHODDEF \
759 {"_register_task", _PyCFunction_CAST(_asyncio__register_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__},
760
761 static PyObject *
762 _asyncio__register_task_impl(PyObject *module, PyObject *task);
763
764 static PyObject *
_asyncio__register_task(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)765 _asyncio__register_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
766 {
767 PyObject *return_value = NULL;
768 static const char * const _keywords[] = {"task", NULL};
769 static _PyArg_Parser _parser = {NULL, _keywords, "_register_task", 0};
770 PyObject *argsbuf[1];
771 PyObject *task;
772
773 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
774 if (!args) {
775 goto exit;
776 }
777 task = args[0];
778 return_value = _asyncio__register_task_impl(module, task);
779
780 exit:
781 return return_value;
782 }
783
784 PyDoc_STRVAR(_asyncio__unregister_task__doc__,
785 "_unregister_task($module, /, task)\n"
786 "--\n"
787 "\n"
788 "Unregister a task.\n"
789 "\n"
790 "Returns None.");
791
792 #define _ASYNCIO__UNREGISTER_TASK_METHODDEF \
793 {"_unregister_task", _PyCFunction_CAST(_asyncio__unregister_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__},
794
795 static PyObject *
796 _asyncio__unregister_task_impl(PyObject *module, PyObject *task);
797
798 static PyObject *
_asyncio__unregister_task(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)799 _asyncio__unregister_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
800 {
801 PyObject *return_value = NULL;
802 static const char * const _keywords[] = {"task", NULL};
803 static _PyArg_Parser _parser = {NULL, _keywords, "_unregister_task", 0};
804 PyObject *argsbuf[1];
805 PyObject *task;
806
807 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
808 if (!args) {
809 goto exit;
810 }
811 task = args[0];
812 return_value = _asyncio__unregister_task_impl(module, task);
813
814 exit:
815 return return_value;
816 }
817
818 PyDoc_STRVAR(_asyncio__enter_task__doc__,
819 "_enter_task($module, /, loop, task)\n"
820 "--\n"
821 "\n"
822 "Enter into task execution or resume suspended task.\n"
823 "\n"
824 "Task belongs to loop.\n"
825 "\n"
826 "Returns None.");
827
828 #define _ASYNCIO__ENTER_TASK_METHODDEF \
829 {"_enter_task", _PyCFunction_CAST(_asyncio__enter_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__},
830
831 static PyObject *
832 _asyncio__enter_task_impl(PyObject *module, PyObject *loop, PyObject *task);
833
834 static PyObject *
_asyncio__enter_task(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)835 _asyncio__enter_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
836 {
837 PyObject *return_value = NULL;
838 static const char * const _keywords[] = {"loop", "task", NULL};
839 static _PyArg_Parser _parser = {NULL, _keywords, "_enter_task", 0};
840 PyObject *argsbuf[2];
841 PyObject *loop;
842 PyObject *task;
843
844 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
845 if (!args) {
846 goto exit;
847 }
848 loop = args[0];
849 task = args[1];
850 return_value = _asyncio__enter_task_impl(module, loop, task);
851
852 exit:
853 return return_value;
854 }
855
856 PyDoc_STRVAR(_asyncio__leave_task__doc__,
857 "_leave_task($module, /, loop, task)\n"
858 "--\n"
859 "\n"
860 "Leave task execution or suspend a task.\n"
861 "\n"
862 "Task belongs to loop.\n"
863 "\n"
864 "Returns None.");
865
866 #define _ASYNCIO__LEAVE_TASK_METHODDEF \
867 {"_leave_task", _PyCFunction_CAST(_asyncio__leave_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__},
868
869 static PyObject *
870 _asyncio__leave_task_impl(PyObject *module, PyObject *loop, PyObject *task);
871
872 static PyObject *
_asyncio__leave_task(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)873 _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
874 {
875 PyObject *return_value = NULL;
876 static const char * const _keywords[] = {"loop", "task", NULL};
877 static _PyArg_Parser _parser = {NULL, _keywords, "_leave_task", 0};
878 PyObject *argsbuf[2];
879 PyObject *loop;
880 PyObject *task;
881
882 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
883 if (!args) {
884 goto exit;
885 }
886 loop = args[0];
887 task = args[1];
888 return_value = _asyncio__leave_task_impl(module, loop, task);
889
890 exit:
891 return return_value;
892 }
893 /*[clinic end generated code: output=b4e678c915567934 input=a9049054013a1b77]*/
894