Debian Codegraph @

Modules/clinic/_asynciomodule.c.h

raw
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
8 #endif
9 #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION()
10 #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
11
12 PyDoc_STRVAR(_asyncio_Future___init____doc__,
13 "Future(*, loop=None)\n"
14 "--\n"
15 "\n"
16 "This class is *almost* compatible with concurrent.futures.Future.\n"
17 "\n"
18 " Differences:\n"
19 "\n"
20 " - result() and exception() do not take a timeout argument and\n"
21 " raise an exception when the future isn\'t done yet.\n"
22 "\n"
23 " - Callbacks registered with add_done_callback() are always called\n"
24 " via the event loop\'s call_soon_threadsafe().\n"
25 "\n"
26 " - This class is not compatible with the wait() and as_completed()\n"
27 " methods in the concurrent.futures package.");
28
29 static int
30 _asyncio_Future___init___impl(FutureObj *self, PyObject *loop);
31
32 static int
33 _asyncio_Future___init__(PyObject *self, PyObject *args, PyObject *kwargs)
34 {
35 int return_value = -1;
36 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
37
38 #define NUM_KEYWORDS 1
39 static struct {
40 PyGC_Head _this_is_not_used;
41 PyObject_VAR_HEAD
42 Py_hash_t ob_hash;
43 PyObject *ob_item[NUM_KEYWORDS];
44 } _kwtuple = {
45 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
46 .ob_hash = -1,
47 .ob_item = { &_Py_ID(loop), },
48 };
49 #undef NUM_KEYWORDS
50 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
51
52 #else // !Py_BUILD_CORE
53 # define KWTUPLE NULL
54 #endif // !Py_BUILD_CORE
55
56 static const char * const _keywords[] = {"loop", NULL};
57 static _PyArg_Parser _parser = {
58 .keywords = _keywords,
59 .fname = "Future",
60 .kwtuple = KWTUPLE,
61 };
62 #undef KWTUPLE
63 PyObject *argsbuf[1];
64 PyObject * const *fastargs;
65 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
66 Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
67 PyObject *loop = Py_None;
68
69 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
70 /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
71 if (!fastargs) {
72 goto exit;
73 }
74 if (!noptargs) {
75 goto skip_optional_kwonly;
76 }
77 loop = fastargs[0];
78 skip_optional_kwonly:
79 return_value = _asyncio_Future___init___impl((FutureObj *)self, loop);
80
81 exit:
82 return return_value;
83 }
84
85 PyDoc_STRVAR(_asyncio_Future_result__doc__,
86 "result($self, /)\n"
87 "--\n"
88 "\n"
89 "Return the result this future represents.\n"
90 "\n"
91 "If the future has been cancelled, raises CancelledError. If the\n"
92 "future\'s result isn\'t yet available, raises InvalidStateError. If\n"
93 "the future is done and has an exception set, this exception is\n"
94 "raised.");
95
96 #define _ASYNCIO_FUTURE_RESULT_METHODDEF \
97 {"result", (PyCFunction)_asyncio_Future_result, METH_NOARGS, _asyncio_Future_result__doc__},
98
99 static PyObject *
100 _asyncio_Future_result_impl(FutureObj *self);
101
102 static PyObject *
103 _asyncio_Future_result(PyObject *self, PyObject *Py_UNUSED(ignored))
104 {
105 PyObject *return_value = NULL;
106
107 Py_BEGIN_CRITICAL_SECTION(self);
108 return_value = _asyncio_Future_result_impl((FutureObj *)self);
109 Py_END_CRITICAL_SECTION();
110
111 return return_value;
112 }
113
114 PyDoc_STRVAR(_asyncio_Future_exception__doc__,
115 "exception($self, /)\n"
116 "--\n"
117 "\n"
118 "Return the exception that was set on this future.\n"
119 "\n"
120 "The exception (or None if no exception was set) is returned only if\n"
121 "the future is done. If the future has been cancelled, raises\n"
122 "CancelledError. If the future isn\'t done yet, raises\n"
123 "InvalidStateError.");
124
125 #define _ASYNCIO_FUTURE_EXCEPTION_METHODDEF \
126 {"exception", _PyCFunction_CAST(_asyncio_Future_exception), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_exception__doc__},
127
128 static PyObject *
129 _asyncio_Future_exception_impl(FutureObj *self, PyTypeObject *cls);
130
131 static PyObject *
132 _asyncio_Future_exception(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
133 {
134 PyObject *return_value = NULL;
135
136 if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
137 PyErr_SetString(PyExc_TypeError, "exception() takes no arguments");
138 goto exit;
139 }
140 Py_BEGIN_CRITICAL_SECTION(self);
141 return_value = _asyncio_Future_exception_impl((FutureObj *)self, cls);
142 Py_END_CRITICAL_SECTION();
143
144 exit:
145 return return_value;
146 }
147
148 PyDoc_STRVAR(_asyncio_Future_set_result__doc__,
149 "set_result($self, result, /)\n"
150 "--\n"
151 "\n"
152 "Mark the future done and set its result.\n"
153 "\n"
154 "If the future is already done when this method is called, raises\n"
155 "InvalidStateError.");
156
157 #define _ASYNCIO_FUTURE_SET_RESULT_METHODDEF \
158 {"set_result", _PyCFunction_CAST(_asyncio_Future_set_result), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_set_result__doc__},
159
160 static PyObject *
161 _asyncio_Future_set_result_impl(FutureObj *self, PyTypeObject *cls,
162 PyObject *result);
163
164 static PyObject *
165 _asyncio_Future_set_result(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
166 {
167 PyObject *return_value = NULL;
168 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
169 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
170 #else
171 # define KWTUPLE NULL
172 #endif
173
174 static const char * const _keywords[] = {"", NULL};
175 static _PyArg_Parser _parser = {
176 .keywords = _keywords,
177 .fname = "set_result",
178 .kwtuple = KWTUPLE,
179 };
180 #undef KWTUPLE
181 PyObject *argsbuf[1];
182 PyObject *result;
183
184 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
185 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
186 if (!args) {
187 goto exit;
188 }
189 result = args[0];
190 Py_BEGIN_CRITICAL_SECTION(self);
191 return_value = _asyncio_Future_set_result_impl((FutureObj *)self, cls, result);
192 Py_END_CRITICAL_SECTION();
193
194 exit:
195 return return_value;
196 }
197
198 PyDoc_STRVAR(_asyncio_Future_set_exception__doc__,
199 "set_exception($self, exception, /)\n"
200 "--\n"
201 "\n"
202 "Mark the future done and set an exception.\n"
203 "\n"
204 "If the future is already done when this method is called, raises\n"
205 "InvalidStateError.");
206
207 #define _ASYNCIO_FUTURE_SET_EXCEPTION_METHODDEF \
208 {"set_exception", _PyCFunction_CAST(_asyncio_Future_set_exception), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_set_exception__doc__},
209
210 static PyObject *
211 _asyncio_Future_set_exception_impl(FutureObj *self, PyTypeObject *cls,
212 PyObject *exception);
213
214 static PyObject *
215 _asyncio_Future_set_exception(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
216 {
217 PyObject *return_value = NULL;
218 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
219 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
220 #else
221 # define KWTUPLE NULL
222 #endif
223
224 static const char * const _keywords[] = {"", NULL};
225 static _PyArg_Parser _parser = {
226 .keywords = _keywords,
227 .fname = "set_exception",
228 .kwtuple = KWTUPLE,
229 };
230 #undef KWTUPLE
231 PyObject *argsbuf[1];
232 PyObject *exception;
233
234 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
235 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
236 if (!args) {
237 goto exit;
238 }
239 exception = args[0];
240 Py_BEGIN_CRITICAL_SECTION(self);
241 return_value = _asyncio_Future_set_exception_impl((FutureObj *)self, cls, exception);
242 Py_END_CRITICAL_SECTION();
243
244 exit:
245 return return_value;
246 }
247
248 PyDoc_STRVAR(_asyncio_Future_add_done_callback__doc__,
249 "add_done_callback($self, fn, /, *, context=<unrepresentable>)\n"
250 "--\n"
251 "\n"
252 "Add a callback to be run when the future becomes done.\n"
253 "\n"
254 "The callback is called with a single argument - the future object.\n"
255 "If the future is already done when this is called, the callback is\n"
256 "scheduled with call_soon.");
257
258 #define _ASYNCIO_FUTURE_ADD_DONE_CALLBACK_METHODDEF \
259 {"add_done_callback", _PyCFunction_CAST(_asyncio_Future_add_done_callback), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_add_done_callback__doc__},
260
261 static PyObject *
262 _asyncio_Future_add_done_callback_impl(FutureObj *self, PyTypeObject *cls,
263 PyObject *fn, PyObject *context);
264
265 static PyObject *
266 _asyncio_Future_add_done_callback(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
267 {
268 PyObject *return_value = NULL;
269 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
270
271 #define NUM_KEYWORDS 1
272 static struct {
273 PyGC_Head _this_is_not_used;
274 PyObject_VAR_HEAD
275 Py_hash_t ob_hash;
276 PyObject *ob_item[NUM_KEYWORDS];
277 } _kwtuple = {
278 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
279 .ob_hash = -1,
280 .ob_item = { &_Py_ID(context), },
281 };
282 #undef NUM_KEYWORDS
283 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
284
285 #else // !Py_BUILD_CORE
286 # define KWTUPLE NULL
287 #endif // !Py_BUILD_CORE
288
289 static const char * const _keywords[] = {"", "context", NULL};
290 static _PyArg_Parser _parser = {
291 .keywords = _keywords,
292 .fname = "add_done_callback",
293 .kwtuple = KWTUPLE,
294 };
295 #undef KWTUPLE
296 PyObject *argsbuf[2];
297 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
298 PyObject *fn;
299 PyObject *context = NULL;
300
301 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
302 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
303 if (!args) {
304 goto exit;
305 }
306 fn = args[0];
307 if (!noptargs) {
308 goto skip_optional_kwonly;
309 }
310 context = args[1];
311 skip_optional_kwonly:
312 Py_BEGIN_CRITICAL_SECTION(self);
313 return_value = _asyncio_Future_add_done_callback_impl((FutureObj *)self, cls, fn, context);
314 Py_END_CRITICAL_SECTION();
315
316 exit:
317 return return_value;
318 }
319
320 PyDoc_STRVAR(_asyncio_Future_remove_done_callback__doc__,
321 "remove_done_callback($self, fn, /)\n"
322 "--\n"
323 "\n"
324 "Remove all instances of a callback from the \"call when done\" list.\n"
325 "\n"
326 "Returns the number of callbacks removed.");
327
328 #define _ASYNCIO_FUTURE_REMOVE_DONE_CALLBACK_METHODDEF \
329 {"remove_done_callback", _PyCFunction_CAST(_asyncio_Future_remove_done_callback), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_remove_done_callback__doc__},
330
331 static PyObject *
332 _asyncio_Future_remove_done_callback_impl(FutureObj *self, PyTypeObject *cls,
333 PyObject *fn);
334
335 static PyObject *
336 _asyncio_Future_remove_done_callback(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
337 {
338 PyObject *return_value = NULL;
339 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
340 # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
341 #else
342 # define KWTUPLE NULL
343 #endif
344
345 static const char * const _keywords[] = {"", NULL};
346 static _PyArg_Parser _parser = {
347 .keywords = _keywords,
348 .fname = "remove_done_callback",
349 .kwtuple = KWTUPLE,
350 };
351 #undef KWTUPLE
352 PyObject *argsbuf[1];
353 PyObject *fn;
354
355 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
356 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
357 if (!args) {
358 goto exit;
359 }
360 fn = args[0];
361 Py_BEGIN_CRITICAL_SECTION(self);
362 return_value = _asyncio_Future_remove_done_callback_impl((FutureObj *)self, cls, fn);
363 Py_END_CRITICAL_SECTION();
364
365 exit:
366 return return_value;
367 }
368
369 PyDoc_STRVAR(_asyncio_Future_cancel__doc__,
370 "cancel($self, /, msg=None)\n"
371 "--\n"
372 "\n"
373 "Cancel the future and schedule callbacks.\n"
374 "\n"
375 "If the future is already done or cancelled, return False.\n"
376 "Otherwise, change the future\'s state to cancelled, schedule the\n"
377 "callbacks and return True.");
378
379 #define _ASYNCIO_FUTURE_CANCEL_METHODDEF \
380 {"cancel", _PyCFunction_CAST(_asyncio_Future_cancel), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_cancel__doc__},
381
382 static PyObject *
383 _asyncio_Future_cancel_impl(FutureObj *self, PyTypeObject *cls,
384 PyObject *msg);
385
386 static PyObject *
387 _asyncio_Future_cancel(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
388 {
389 PyObject *return_value = NULL;
390 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
391
392 #define NUM_KEYWORDS 1
393 static struct {
394 PyGC_Head _this_is_not_used;
395 PyObject_VAR_HEAD
396 Py_hash_t ob_hash;
397 PyObject *ob_item[NUM_KEYWORDS];
398 } _kwtuple = {
399 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
400 .ob_hash = -1,
401 .ob_item = { &_Py_ID(msg), },
402 };
403 #undef NUM_KEYWORDS
404 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
405
406 #else // !Py_BUILD_CORE
407 # define KWTUPLE NULL
408 #endif // !Py_BUILD_CORE
409
410 static const char * const _keywords[] = {"msg", NULL};
411 static _PyArg_Parser _parser = {
412 .keywords = _keywords,
413 .fname = "cancel",
414 .kwtuple = KWTUPLE,
415 };
416 #undef KWTUPLE
417 PyObject *argsbuf[1];
418 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
419 PyObject *msg = Py_None;
420
421 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
422 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
423 if (!args) {
424 goto exit;
425 }
426 if (!noptargs) {
427 goto skip_optional_pos;
428 }
429 msg = args[0];
430 skip_optional_pos:
431 Py_BEGIN_CRITICAL_SECTION(self);
432 return_value = _asyncio_Future_cancel_impl((FutureObj *)self, cls, msg);
433 Py_END_CRITICAL_SECTION();
434
435 exit:
436 return return_value;
437 }
438
439 PyDoc_STRVAR(_asyncio_Future_cancelled__doc__,
440 "cancelled($self, /)\n"
441 "--\n"
442 "\n"
443 "Return True if the future was cancelled.");
444
445 #define _ASYNCIO_FUTURE_CANCELLED_METHODDEF \
446 {"cancelled", (PyCFunction)_asyncio_Future_cancelled, METH_NOARGS, _asyncio_Future_cancelled__doc__},
447
448 static PyObject *
449 _asyncio_Future_cancelled_impl(FutureObj *self);
450
451 static PyObject *
452 _asyncio_Future_cancelled(PyObject *self, PyObject *Py_UNUSED(ignored))
453 {
454 PyObject *return_value = NULL;
455
456 Py_BEGIN_CRITICAL_SECTION(self);
457 return_value = _asyncio_Future_cancelled_impl((FutureObj *)self);
458 Py_END_CRITICAL_SECTION();
459
460 return return_value;
461 }
462
463 PyDoc_STRVAR(_asyncio_Future_done__doc__,
464 "done($self, /)\n"
465 "--\n"
466 "\n"
467 "Return True if the future is done.\n"
468 "\n"
469 "Done means either that a result / exception are available, or that\n"
470 "the future was cancelled.");
471
472 #define _ASYNCIO_FUTURE_DONE_METHODDEF \
473 {"done", (PyCFunction)_asyncio_Future_done, METH_NOARGS, _asyncio_Future_done__doc__},
474
475 static PyObject *
476 _asyncio_Future_done_impl(FutureObj *self);
477
478 static PyObject *
479 _asyncio_Future_done(PyObject *self, PyObject *Py_UNUSED(ignored))
480 {
481 PyObject *return_value = NULL;
482
483 Py_BEGIN_CRITICAL_SECTION(self);
484 return_value = _asyncio_Future_done_impl((FutureObj *)self);
485 Py_END_CRITICAL_SECTION();
486
487 return return_value;
488 }
489
490 PyDoc_STRVAR(_asyncio_Future_get_loop__doc__,
491 "get_loop($self, /)\n"
492 "--\n"
493 "\n"
494 "Return the event loop the Future is bound to.");
495
496 #define _ASYNCIO_FUTURE_GET_LOOP_METHODDEF \
497 {"get_loop", _PyCFunction_CAST(_asyncio_Future_get_loop), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_get_loop__doc__},
498
499 static PyObject *
500 _asyncio_Future_get_loop_impl(FutureObj *self, PyTypeObject *cls);
501
502 static PyObject *
503 _asyncio_Future_get_loop(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
504 {
505 PyObject *return_value = NULL;
506
507 if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
508 PyErr_SetString(PyExc_TypeError, "get_loop() takes no arguments");
509 goto exit;
510 }
511 Py_BEGIN_CRITICAL_SECTION(self);
512 return_value = _asyncio_Future_get_loop_impl((FutureObj *)self, cls);
513 Py_END_CRITICAL_SECTION();
514
515 exit:
516 return return_value;
517 }
518
519 #if !defined(_asyncio_Future__asyncio_awaited_by_DOCSTR)
520 # define _asyncio_Future__asyncio_awaited_by_DOCSTR NULL
521 #endif
522 #if defined(_ASYNCIO_FUTURE__ASYNCIO_AWAITED_BY_GETSETDEF)
523 # undef _ASYNCIO_FUTURE__ASYNCIO_AWAITED_BY_GETSETDEF
524 # define _ASYNCIO_FUTURE__ASYNCIO_AWAITED_BY_GETSETDEF {"_asyncio_awaited_by", (getter)_asyncio_Future__asyncio_awaited_by_get, (setter)_asyncio_Future__asyncio_awaited_by_set, _asyncio_Future__asyncio_awaited_by_DOCSTR},
525 #else
526 # define _ASYNCIO_FUTURE__ASYNCIO_AWAITED_BY_GETSETDEF {"_asyncio_awaited_by", (getter)_asyncio_Future__asyncio_awaited_by_get, NULL, _asyncio_Future__asyncio_awaited_by_DOCSTR},
527 #endif
528
529 static PyObject *
530 _asyncio_Future__asyncio_awaited_by_get_impl(FutureObj *self);
531
532 static PyObject *
533 _asyncio_Future__asyncio_awaited_by_get(PyObject *self, void *Py_UNUSED(context))
534 {
535 PyObject *return_value = NULL;
536
537 Py_BEGIN_CRITICAL_SECTION(self);
538 return_value = _asyncio_Future__asyncio_awaited_by_get_impl((FutureObj *)self);
539 Py_END_CRITICAL_SECTION();
540
541 return return_value;
542 }
543
544 #if !defined(_asyncio_Future__asyncio_future_blocking_DOCSTR)
545 # define _asyncio_Future__asyncio_future_blocking_DOCSTR NULL
546 #endif
547 #if defined(_ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF)
548 # undef _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF
549 # define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", (getter)_asyncio_Future__asyncio_future_blocking_get, (setter)_asyncio_Future__asyncio_future_blocking_set, _asyncio_Future__asyncio_future_blocking_DOCSTR},
550 #else
551 # define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", (getter)_asyncio_Future__asyncio_future_blocking_get, NULL, _asyncio_Future__asyncio_future_blocking_DOCSTR},
552 #endif
553
554 static PyObject *
555 _asyncio_Future__asyncio_future_blocking_get_impl(FutureObj *self);
556
557 static PyObject *
558 _asyncio_Future__asyncio_future_blocking_get(PyObject *self, void *Py_UNUSED(context))
559 {
560 PyObject *return_value = NULL;
561
562 Py_BEGIN_CRITICAL_SECTION(self);
563 return_value = _asyncio_Future__asyncio_future_blocking_get_impl((FutureObj *)self);
564 Py_END_CRITICAL_SECTION();
565
566 return return_value;
567 }
568
569 #if !defined(_asyncio_Future__asyncio_future_blocking_DOCSTR)
570 # define _asyncio_Future__asyncio_future_blocking_DOCSTR NULL
571 #endif
572 #if defined(_ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF)
573 # undef _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF
574 # define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", (getter)_asyncio_Future__asyncio_future_blocking_get, (setter)_asyncio_Future__asyncio_future_blocking_set, _asyncio_Future__asyncio_future_blocking_DOCSTR},
575 #else
576 # define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", NULL, (setter)_asyncio_Future__asyncio_future_blocking_set, NULL},
577 #endif
578
579 static int
580 _asyncio_Future__asyncio_future_blocking_set_impl(FutureObj *self,
581 PyObject *value);
582
583 static int
584 _asyncio_Future__asyncio_future_blocking_set(PyObject *self, PyObject *value, void *Py_UNUSED(context))
585 {
586 int return_value;
587
588 Py_BEGIN_CRITICAL_SECTION(self);
589 return_value = _asyncio_Future__asyncio_future_blocking_set_impl((FutureObj *)self, value);
590 Py_END_CRITICAL_SECTION();
591
592 return return_value;
593 }
594
595 #if !defined(_asyncio_Future__log_traceback_DOCSTR)
596 # define _asyncio_Future__log_traceback_DOCSTR NULL
597 #endif
598 #if defined(_ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF)
599 # undef _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF
600 # define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", (getter)_asyncio_Future__log_traceback_get, (setter)_asyncio_Future__log_traceback_set, _asyncio_Future__log_traceback_DOCSTR},
601 #else
602 # define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", (getter)_asyncio_Future__log_traceback_get, NULL, _asyncio_Future__log_traceback_DOCSTR},
603 #endif
604
605 static PyObject *
606 _asyncio_Future__log_traceback_get_impl(FutureObj *self);
607
608 static PyObject *
609 _asyncio_Future__log_traceback_get(PyObject *self, void *Py_UNUSED(context))
610 {
611 PyObject *return_value = NULL;
612
613 Py_BEGIN_CRITICAL_SECTION(self);
614 return_value = _asyncio_Future__log_traceback_get_impl((FutureObj *)self);
615 Py_END_CRITICAL_SECTION();
616
617 return return_value;
618 }
619
620 #if !defined(_asyncio_Future__log_traceback_DOCSTR)
621 # define _asyncio_Future__log_traceback_DOCSTR NULL
622 #endif
623 #if defined(_ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF)
624 # undef _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF
625 # define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", (getter)_asyncio_Future__log_traceback_get, (setter)_asyncio_Future__log_traceback_set, _asyncio_Future__log_traceback_DOCSTR},
626 #else
627 # define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", NULL, (setter)_asyncio_Future__log_traceback_set, NULL},
628 #endif
629
630 static int
631 _asyncio_Future__log_traceback_set_impl(FutureObj *self, PyObject *value);
632
633 static int
634 _asyncio_Future__log_traceback_set(PyObject *self, PyObject *value, void *Py_UNUSED(context))
635 {
636 int return_value;
637
638 Py_BEGIN_CRITICAL_SECTION(self);
639 return_value = _asyncio_Future__log_traceback_set_impl((FutureObj *)self, value);
640 Py_END_CRITICAL_SECTION();
641
642 return return_value;
643 }
644
645 #if !defined(_asyncio_Future__loop_DOCSTR)
646 # define _asyncio_Future__loop_DOCSTR NULL
647 #endif
648 #if defined(_ASYNCIO_FUTURE__LOOP_GETSETDEF)
649 # undef _ASYNCIO_FUTURE__LOOP_GETSETDEF
650 # define _ASYNCIO_FUTURE__LOOP_GETSETDEF {"_loop", (getter)_asyncio_Future__loop_get, (setter)_asyncio_Future__loop_set, _asyncio_Future__loop_DOCSTR},
651 #else
652 # define _ASYNCIO_FUTURE__LOOP_GETSETDEF {"_loop", (getter)_asyncio_Future__loop_get, NULL, _asyncio_Future__loop_DOCSTR},
653 #endif
654
655 static PyObject *
656 _asyncio_Future__loop_get_impl(FutureObj *self);
657
658 static PyObject *
659 _asyncio_Future__loop_get(PyObject *self, void *Py_UNUSED(context))
660 {
661 PyObject *return_value = NULL;
662
663 Py_BEGIN_CRITICAL_SECTION(self);
664 return_value = _asyncio_Future__loop_get_impl((FutureObj *)self);
665 Py_END_CRITICAL_SECTION();
666
667 return return_value;
668 }
669
670 #if !defined(_asyncio_Future__callbacks_DOCSTR)
671 # define _asyncio_Future__callbacks_DOCSTR NULL
672 #endif
673 #if defined(_ASYNCIO_FUTURE__CALLBACKS_GETSETDEF)
674 # undef _ASYNCIO_FUTURE__CALLBACKS_GETSETDEF
675 # define _ASYNCIO_FUTURE__CALLBACKS_GETSETDEF {"_callbacks", (getter)_asyncio_Future__callbacks_get, (setter)_asyncio_Future__callbacks_set, _asyncio_Future__callbacks_DOCSTR},
676 #else
677 # define _ASYNCIO_FUTURE__CALLBACKS_GETSETDEF {"_callbacks", (getter)_asyncio_Future__callbacks_get, NULL, _asyncio_Future__callbacks_DOCSTR},
678 #endif
679
680 static PyObject *
681 _asyncio_Future__callbacks_get_impl(FutureObj *self);
682
683 static PyObject *
684 _asyncio_Future__callbacks_get(PyObject *self, void *Py_UNUSED(context))
685 {
686 PyObject *return_value = NULL;
687
688 Py_BEGIN_CRITICAL_SECTION(self);
689 return_value = _asyncio_Future__callbacks_get_impl((FutureObj *)self);
690 Py_END_CRITICAL_SECTION();
691
692 return return_value;
693 }
694
695 #if !defined(_asyncio_Future__result_DOCSTR)
696 # define _asyncio_Future__result_DOCSTR NULL
697 #endif
698 #if defined(_ASYNCIO_FUTURE__RESULT_GETSETDEF)
699 # undef _ASYNCIO_FUTURE__RESULT_GETSETDEF
700 # define _ASYNCIO_FUTURE__RESULT_GETSETDEF {"_result", (getter)_asyncio_Future__result_get, (setter)_asyncio_Future__result_set, _asyncio_Future__result_DOCSTR},
701 #else
702 # define _ASYNCIO_FUTURE__RESULT_GETSETDEF {"_result", (getter)_asyncio_Future__result_get, NULL, _asyncio_Future__result_DOCSTR},
703 #endif
704
705 static PyObject *
706 _asyncio_Future__result_get_impl(FutureObj *self);
707
708 static PyObject *
709 _asyncio_Future__result_get(PyObject *self, void *Py_UNUSED(context))
710 {
711 PyObject *return_value = NULL;
712
713 Py_BEGIN_CRITICAL_SECTION(self);
714 return_value = _asyncio_Future__result_get_impl((FutureObj *)self);
715 Py_END_CRITICAL_SECTION();
716
717 return return_value;
718 }
719
720 #if !defined(_asyncio_Future__exception_DOCSTR)
721 # define _asyncio_Future__exception_DOCSTR NULL
722 #endif
723 #if defined(_ASYNCIO_FUTURE__EXCEPTION_GETSETDEF)
724 # undef _ASYNCIO_FUTURE__EXCEPTION_GETSETDEF
725 # define _ASYNCIO_FUTURE__EXCEPTION_GETSETDEF {"_exception", (getter)_asyncio_Future__exception_get, (setter)_asyncio_Future__exception_set, _asyncio_Future__exception_DOCSTR},
726 #else
727 # define _ASYNCIO_FUTURE__EXCEPTION_GETSETDEF {"_exception", (getter)_asyncio_Future__exception_get, NULL, _asyncio_Future__exception_DOCSTR},
728 #endif
729
730 static PyObject *
731 _asyncio_Future__exception_get_impl(FutureObj *self);
732
733 static PyObject *
734 _asyncio_Future__exception_get(PyObject *self, void *Py_UNUSED(context))
735 {
736 PyObject *return_value = NULL;
737
738 Py_BEGIN_CRITICAL_SECTION(self);
739 return_value = _asyncio_Future__exception_get_impl((FutureObj *)self);
740 Py_END_CRITICAL_SECTION();
741
742 return return_value;
743 }
744
745 #if !defined(_asyncio_Future__source_traceback_DOCSTR)
746 # define _asyncio_Future__source_traceback_DOCSTR NULL
747 #endif
748 #if defined(_ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF)
749 # undef _ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF
750 # define _ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF {"_source_traceback", (getter)_asyncio_Future__source_traceback_get, (setter)_asyncio_Future__source_traceback_set, _asyncio_Future__source_traceback_DOCSTR},
751 #else
752 # define _ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF {"_source_traceback", (getter)_asyncio_Future__source_traceback_get, NULL, _asyncio_Future__source_traceback_DOCSTR},
753 #endif
754
755 static PyObject *
756 _asyncio_Future__source_traceback_get_impl(FutureObj *self);
757
758 static PyObject *
759 _asyncio_Future__source_traceback_get(PyObject *self, void *Py_UNUSED(context))
760 {
761 PyObject *return_value = NULL;
762
763 Py_BEGIN_CRITICAL_SECTION(self);
764 return_value = _asyncio_Future__source_traceback_get_impl((FutureObj *)self);
765 Py_END_CRITICAL_SECTION();
766
767 return return_value;
768 }
769
770 #if !defined(_asyncio_Future__cancel_message_DOCSTR)
771 # define _asyncio_Future__cancel_message_DOCSTR NULL
772 #endif
773 #if defined(_ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF)
774 # undef _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF
775 # define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", (getter)_asyncio_Future__cancel_message_get, (setter)_asyncio_Future__cancel_message_set, _asyncio_Future__cancel_message_DOCSTR},
776 #else
777 # define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", (getter)_asyncio_Future__cancel_message_get, NULL, _asyncio_Future__cancel_message_DOCSTR},
778 #endif
779
780 static PyObject *
781 _asyncio_Future__cancel_message_get_impl(FutureObj *self);
782
783 static PyObject *
784 _asyncio_Future__cancel_message_get(PyObject *self, void *Py_UNUSED(context))
785 {
786 PyObject *return_value = NULL;
787
788 Py_BEGIN_CRITICAL_SECTION(self);
789 return_value = _asyncio_Future__cancel_message_get_impl((FutureObj *)self);
790 Py_END_CRITICAL_SECTION();
791
792 return return_value;
793 }
794
795 #if !defined(_asyncio_Future__cancel_message_DOCSTR)
796 # define _asyncio_Future__cancel_message_DOCSTR NULL
797 #endif
798 #if defined(_ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF)
799 # undef _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF
800 # define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", (getter)_asyncio_Future__cancel_message_get, (setter)_asyncio_Future__cancel_message_set, _asyncio_Future__cancel_message_DOCSTR},
801 #else
802 # define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", NULL, (setter)_asyncio_Future__cancel_message_set, NULL},
803 #endif
804
805 static int
806 _asyncio_Future__cancel_message_set_impl(FutureObj *self, PyObject *value);
807
808 static int
809 _asyncio_Future__cancel_message_set(PyObject *self, PyObject *value, void *Py_UNUSED(context))
810 {
811 int return_value;
812
813 Py_BEGIN_CRITICAL_SECTION(self);
814 return_value = _asyncio_Future__cancel_message_set_impl((FutureObj *)self, value);
815 Py_END_CRITICAL_SECTION();
816
817 return return_value;
818 }
819
820 #if !defined(_asyncio_Future__state_DOCSTR)
821 # define _asyncio_Future__state_DOCSTR NULL
822 #endif
823 #if defined(_ASYNCIO_FUTURE__STATE_GETSETDEF)
824 # undef _ASYNCIO_FUTURE__STATE_GETSETDEF
825 # define _ASYNCIO_FUTURE__STATE_GETSETDEF {"_state", (getter)_asyncio_Future__state_get, (setter)_asyncio_Future__state_set, _asyncio_Future__state_DOCSTR},
826 #else
827 # define _ASYNCIO_FUTURE__STATE_GETSETDEF {"_state", (getter)_asyncio_Future__state_get, NULL, _asyncio_Future__state_DOCSTR},
828 #endif
829
830 static PyObject *
831 _asyncio_Future__state_get_impl(FutureObj *self);
832
833 static PyObject *
834 _asyncio_Future__state_get(PyObject *self, void *Py_UNUSED(context))
835 {
836 PyObject *return_value = NULL;
837
838 Py_BEGIN_CRITICAL_SECTION(self);
839 return_value = _asyncio_Future__state_get_impl((FutureObj *)self);
840 Py_END_CRITICAL_SECTION();
841
842 return return_value;
843 }
844
845 PyDoc_STRVAR(_asyncio_Future__make_cancelled_error__doc__,
846 "_make_cancelled_error($self, /)\n"
847 "--\n"
848 "\n"
849 "Create the CancelledError to raise if the Future is cancelled.\n"
850 "\n"
851 "This should only be called once when handling a cancellation since\n"
852 "it erases the context exception value.");
853
854 #define _ASYNCIO_FUTURE__MAKE_CANCELLED_ERROR_METHODDEF \
855 {"_make_cancelled_error", (PyCFunction)_asyncio_Future__make_cancelled_error, METH_NOARGS, _asyncio_Future__make_cancelled_error__doc__},
856
857 static PyObject *
858 _asyncio_Future__make_cancelled_error_impl(FutureObj *self);
859
860 static PyObject *
861 _asyncio_Future__make_cancelled_error(PyObject *self, PyObject *Py_UNUSED(ignored))
862 {
863 PyObject *return_value = NULL;
864
865 Py_BEGIN_CRITICAL_SECTION(self);
866 return_value = _asyncio_Future__make_cancelled_error_impl((FutureObj *)self);
867 Py_END_CRITICAL_SECTION();
868
869 return return_value;
870 }
871
872 PyDoc_STRVAR(_asyncio_Task___init____doc__,
873 "Task(coro, *, loop=None, name=None, context=None, eager_start=False)\n"
874 "--\n"
875 "\n"
876 "A coroutine wrapped in a Future.");
877
878 static int
879 _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop,
880 PyObject *name, PyObject *context,
881 int eager_start);
882
883 static int
884 _asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs)
885 {
886 int return_value = -1;
887 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
888
889 #define NUM_KEYWORDS 5
890 static struct {
891 PyGC_Head _this_is_not_used;
892 PyObject_VAR_HEAD
893 Py_hash_t ob_hash;
894 PyObject *ob_item[NUM_KEYWORDS];
895 } _kwtuple = {
896 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
897 .ob_hash = -1,
898 .ob_item = { &_Py_ID(coro), &_Py_ID(loop), &_Py_ID(name), &_Py_ID(context), &_Py_ID(eager_start), },
899 };
900 #undef NUM_KEYWORDS
901 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
902
903 #else // !Py_BUILD_CORE
904 # define KWTUPLE NULL
905 #endif // !Py_BUILD_CORE
906
907 static const char * const _keywords[] = {"coro", "loop", "name", "context", "eager_start", NULL};
908 static _PyArg_Parser _parser = {
909 .keywords = _keywords,
910 .fname = "Task",
911 .kwtuple = KWTUPLE,
912 };
913 #undef KWTUPLE
914 PyObject *argsbuf[5];
915 PyObject * const *fastargs;
916 Py_ssize_t nargs = PyTuple_GET_SIZE(args);
917 Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
918 PyObject *coro;
919 PyObject *loop = Py_None;
920 PyObject *name = Py_None;
921 PyObject *context = Py_None;
922 int eager_start = 0;
923
924 fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
925 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
926 if (!fastargs) {
927 goto exit;
928 }
929 coro = fastargs[0];
930 if (!noptargs) {
931 goto skip_optional_kwonly;
932 }
933 if (fastargs[1]) {
934 loop = fastargs[1];
935 if (!--noptargs) {
936 goto skip_optional_kwonly;
937 }
938 }
939 if (fastargs[2]) {
940 name = fastargs[2];
941 if (!--noptargs) {
942 goto skip_optional_kwonly;
943 }
944 }
945 if (fastargs[3]) {
946 context = fastargs[3];
947 if (!--noptargs) {
948 goto skip_optional_kwonly;
949 }
950 }
951 eager_start = PyObject_IsTrue(fastargs[4]);
952 if (eager_start < 0) {
953 goto exit;
954 }
955 skip_optional_kwonly:
956 return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop, name, context, eager_start);
957
958 exit:
959 return return_value;
960 }
961
962 #if !defined(_asyncio_Task__log_destroy_pending_DOCSTR)
963 # define _asyncio_Task__log_destroy_pending_DOCSTR NULL
964 #endif
965 #if defined(_ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF)
966 # undef _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF
967 # define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", (getter)_asyncio_Task__log_destroy_pending_get, (setter)_asyncio_Task__log_destroy_pending_set, _asyncio_Task__log_destroy_pending_DOCSTR},
968 #else
969 # define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", (getter)_asyncio_Task__log_destroy_pending_get, NULL, _asyncio_Task__log_destroy_pending_DOCSTR},
970 #endif
971
972 static PyObject *
973 _asyncio_Task__log_destroy_pending_get_impl(TaskObj *self);
974
975 static PyObject *
976 _asyncio_Task__log_destroy_pending_get(PyObject *self, void *Py_UNUSED(context))
977 {
978 PyObject *return_value = NULL;
979
980 Py_BEGIN_CRITICAL_SECTION(self);
981 return_value = _asyncio_Task__log_destroy_pending_get_impl((TaskObj *)self);
982 Py_END_CRITICAL_SECTION();
983
984 return return_value;
985 }
986
987 #if !defined(_asyncio_Task__log_destroy_pending_DOCSTR)
988 # define _asyncio_Task__log_destroy_pending_DOCSTR NULL
989 #endif
990 #if defined(_ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF)
991 # undef _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF
992 # define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", (getter)_asyncio_Task__log_destroy_pending_get, (setter)_asyncio_Task__log_destroy_pending_set, _asyncio_Task__log_destroy_pending_DOCSTR},
993 #else
994 # define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", NULL, (setter)_asyncio_Task__log_destroy_pending_set, NULL},
995 #endif
996
997 static int
998 _asyncio_Task__log_destroy_pending_set_impl(TaskObj *self, PyObject *value);
999
1000 static int
1001 _asyncio_Task__log_destroy_pending_set(PyObject *self, PyObject *value, void *Py_UNUSED(context))
1002 {
1003 int return_value;
1004
1005 Py_BEGIN_CRITICAL_SECTION(self);
1006 return_value = _asyncio_Task__log_destroy_pending_set_impl((TaskObj *)self, value);
1007 Py_END_CRITICAL_SECTION();
1008
1009 return return_value;
1010 }
1011
1012 #if !defined(_asyncio_Task__must_cancel_DOCSTR)
1013 # define _asyncio_Task__must_cancel_DOCSTR NULL
1014 #endif
1015 #if defined(_ASYNCIO_TASK__MUST_CANCEL_GETSETDEF)
1016 # undef _ASYNCIO_TASK__MUST_CANCEL_GETSETDEF
1017 # define _ASYNCIO_TASK__MUST_CANCEL_GETSETDEF {"_must_cancel", (getter)_asyncio_Task__must_cancel_get, (setter)_asyncio_Task__must_cancel_set, _asyncio_Task__must_cancel_DOCSTR},
1018 #else
1019 # define _ASYNCIO_TASK__MUST_CANCEL_GETSETDEF {"_must_cancel", (getter)_asyncio_Task__must_cancel_get, NULL, _asyncio_Task__must_cancel_DOCSTR},
1020 #endif
1021
1022 static PyObject *
1023 _asyncio_Task__must_cancel_get_impl(TaskObj *self);
1024
1025 static PyObject *
1026 _asyncio_Task__must_cancel_get(PyObject *self, void *Py_UNUSED(context))
1027 {
1028 PyObject *return_value = NULL;
1029
1030 Py_BEGIN_CRITICAL_SECTION(self);
1031 return_value = _asyncio_Task__must_cancel_get_impl((TaskObj *)self);
1032 Py_END_CRITICAL_SECTION();
1033
1034 return return_value;
1035 }
1036
1037 #if !defined(_asyncio_Task__coro_DOCSTR)
1038 # define _asyncio_Task__coro_DOCSTR NULL
1039 #endif
1040 #if defined(_ASYNCIO_TASK__CORO_GETSETDEF)
1041 # undef _ASYNCIO_TASK__CORO_GETSETDEF
1042 # define _ASYNCIO_TASK__CORO_GETSETDEF {"_coro", (getter)_asyncio_Task__coro_get, (setter)_asyncio_Task__coro_set, _asyncio_Task__coro_DOCSTR},
1043 #else
1044 # define _ASYNCIO_TASK__CORO_GETSETDEF {"_coro", (getter)_asyncio_Task__coro_get, NULL, _asyncio_Task__coro_DOCSTR},
1045 #endif
1046
1047 static PyObject *
1048 _asyncio_Task__coro_get_impl(TaskObj *self);
1049
1050 static PyObject *
1051 _asyncio_Task__coro_get(PyObject *self, void *Py_UNUSED(context))
1052 {
1053 PyObject *return_value = NULL;
1054
1055 Py_BEGIN_CRITICAL_SECTION(self);
1056 return_value = _asyncio_Task__coro_get_impl((TaskObj *)self);
1057 Py_END_CRITICAL_SECTION();
1058
1059 return return_value;
1060 }
1061
1062 #if !defined(_asyncio_Task__fut_waiter_DOCSTR)
1063 # define _asyncio_Task__fut_waiter_DOCSTR NULL
1064 #endif
1065 #if defined(_ASYNCIO_TASK__FUT_WAITER_GETSETDEF)
1066 # undef _ASYNCIO_TASK__FUT_WAITER_GETSETDEF
1067 # define _ASYNCIO_TASK__FUT_WAITER_GETSETDEF {"_fut_waiter", (getter)_asyncio_Task__fut_waiter_get, (setter)_asyncio_Task__fut_waiter_set, _asyncio_Task__fut_waiter_DOCSTR},
1068 #else
1069 # define _ASYNCIO_TASK__FUT_WAITER_GETSETDEF {"_fut_waiter", (getter)_asyncio_Task__fut_waiter_get, NULL, _asyncio_Task__fut_waiter_DOCSTR},
1070 #endif
1071
1072 static PyObject *
1073 _asyncio_Task__fut_waiter_get_impl(TaskObj *self);
1074
1075 static PyObject *
1076 _asyncio_Task__fut_waiter_get(PyObject *self, void *Py_UNUSED(context))
1077 {
1078 PyObject *return_value = NULL;
1079
1080 Py_BEGIN_CRITICAL_SECTION(self);
1081 return_value = _asyncio_Task__fut_waiter_get_impl((TaskObj *)self);
1082 Py_END_CRITICAL_SECTION();
1083
1084 return return_value;
1085 }
1086
1087 PyDoc_STRVAR(_asyncio_Task__make_cancelled_error__doc__,
1088 "_make_cancelled_error($self, /)\n"
1089 "--\n"
1090 "\n"
1091 "Create the CancelledError to raise if the Task is cancelled.\n"
1092 "\n"
1093 "This should only be called once when handling a cancellation since\n"
1094 "it erases the context exception value.");
1095
1096 #define _ASYNCIO_TASK__MAKE_CANCELLED_ERROR_METHODDEF \
1097 {"_make_cancelled_error", (PyCFunction)_asyncio_Task__make_cancelled_error, METH_NOARGS, _asyncio_Task__make_cancelled_error__doc__},
1098
1099 static PyObject *
1100 _asyncio_Task__make_cancelled_error_impl(TaskObj *self);
1101
1102 static PyObject *
1103 _asyncio_Task__make_cancelled_error(PyObject *self, PyObject *Py_UNUSED(ignored))
1104 {
1105 PyObject *return_value = NULL;
1106
1107 Py_BEGIN_CRITICAL_SECTION(self);
1108 return_value = _asyncio_Task__make_cancelled_error_impl((TaskObj *)self);
1109 Py_END_CRITICAL_SECTION();
1110
1111 return return_value;
1112 }
1113
1114 PyDoc_STRVAR(_asyncio_Task_cancel__doc__,
1115 "cancel($self, /, msg=None)\n"
1116 "--\n"
1117 "\n"
1118 "Request that this task cancel itself.\n"
1119 "\n"
1120 "This arranges for a CancelledError to be thrown into the\n"
1121 "wrapped coroutine on the next cycle through the event loop.\n"
1122 "The coroutine then has a chance to clean up or even deny\n"
1123 "the request using try/except/finally.\n"
1124 "\n"
1125 "Unlike Future.cancel, this does not guarantee that the\n"
1126 "task will be cancelled: the exception might be caught and\n"
1127 "acted upon, delaying cancellation of the task or preventing\n"
1128 "cancellation completely. The task may also return a value or\n"
1129 "raise a different exception.\n"
1130 "\n"
1131 "Immediately after this method is called, Task.cancelled() will\n"
1132 "not return True (unless the task was already cancelled). A\n"
1133 "task will be marked as cancelled when the wrapped coroutine\n"
1134 "terminates with a CancelledError exception (even if cancel()\n"
1135 "was not called).\n"
1136 "\n"
1137 "This also increases the task\'s count of cancellation requests.");
1138
1139 #define _ASYNCIO_TASK_CANCEL_METHODDEF \
1140 {"cancel", _PyCFunction_CAST(_asyncio_Task_cancel), METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_cancel__doc__},
1141
1142 static PyObject *
1143 _asyncio_Task_cancel_impl(TaskObj *self, PyObject *msg);
1144
1145 static PyObject *
1146 _asyncio_Task_cancel(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1147 {
1148 PyObject *return_value = NULL;
1149 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1150
1151 #define NUM_KEYWORDS 1
1152 static struct {
1153 PyGC_Head _this_is_not_used;
1154 PyObject_VAR_HEAD
1155 Py_hash_t ob_hash;
1156 PyObject *ob_item[NUM_KEYWORDS];
1157 } _kwtuple = {
1158 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1159 .ob_hash = -1,
1160 .ob_item = { &_Py_ID(msg), },
1161 };
1162 #undef NUM_KEYWORDS
1163 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1164
1165 #else // !Py_BUILD_CORE
1166 # define KWTUPLE NULL
1167 #endif // !Py_BUILD_CORE
1168
1169 static const char * const _keywords[] = {"msg", NULL};
1170 static _PyArg_Parser _parser = {
1171 .keywords = _keywords,
1172 .fname = "cancel",
1173 .kwtuple = KWTUPLE,
1174 };
1175 #undef KWTUPLE
1176 PyObject *argsbuf[1];
1177 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1178 PyObject *msg = Py_None;
1179
1180 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1181 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1182 if (!args) {
1183 goto exit;
1184 }
1185 if (!noptargs) {
1186 goto skip_optional_pos;
1187 }
1188 msg = args[0];
1189 skip_optional_pos:
1190 Py_BEGIN_CRITICAL_SECTION(self);
1191 return_value = _asyncio_Task_cancel_impl((TaskObj *)self, msg);
1192 Py_END_CRITICAL_SECTION();
1193
1194 exit:
1195 return return_value;
1196 }
1197
1198 PyDoc_STRVAR(_asyncio_Task_cancelling__doc__,
1199 "cancelling($self, /)\n"
1200 "--\n"
1201 "\n"
1202 "Return the count of the task\'s cancellation requests.\n"
1203 "\n"
1204 "This count is incremented when .cancel() is called\n"
1205 "and may be decremented using .uncancel().");
1206
1207 #define _ASYNCIO_TASK_CANCELLING_METHODDEF \
1208 {"cancelling", (PyCFunction)_asyncio_Task_cancelling, METH_NOARGS, _asyncio_Task_cancelling__doc__},
1209
1210 static PyObject *
1211 _asyncio_Task_cancelling_impl(TaskObj *self);
1212
1213 static PyObject *
1214 _asyncio_Task_cancelling(PyObject *self, PyObject *Py_UNUSED(ignored))
1215 {
1216 PyObject *return_value = NULL;
1217
1218 Py_BEGIN_CRITICAL_SECTION(self);
1219 return_value = _asyncio_Task_cancelling_impl((TaskObj *)self);
1220 Py_END_CRITICAL_SECTION();
1221
1222 return return_value;
1223 }
1224
1225 PyDoc_STRVAR(_asyncio_Task_uncancel__doc__,
1226 "uncancel($self, /)\n"
1227 "--\n"
1228 "\n"
1229 "Decrement the task\'s count of cancellation requests.\n"
1230 "\n"
1231 "This should be used by tasks that catch CancelledError\n"
1232 "and wish to continue indefinitely until they are cancelled again.\n"
1233 "\n"
1234 "Returns the remaining number of cancellation requests.");
1235
1236 #define _ASYNCIO_TASK_UNCANCEL_METHODDEF \
1237 {"uncancel", (PyCFunction)_asyncio_Task_uncancel, METH_NOARGS, _asyncio_Task_uncancel__doc__},
1238
1239 static PyObject *
1240 _asyncio_Task_uncancel_impl(TaskObj *self);
1241
1242 static PyObject *
1243 _asyncio_Task_uncancel(PyObject *self, PyObject *Py_UNUSED(ignored))
1244 {
1245 PyObject *return_value = NULL;
1246
1247 Py_BEGIN_CRITICAL_SECTION(self);
1248 return_value = _asyncio_Task_uncancel_impl((TaskObj *)self);
1249 Py_END_CRITICAL_SECTION();
1250
1251 return return_value;
1252 }
1253
1254 PyDoc_STRVAR(_asyncio_Task_get_stack__doc__,
1255 "get_stack($self, /, *, limit=None)\n"
1256 "--\n"
1257 "\n"
1258 "Return the list of stack frames for this task\'s coroutine.\n"
1259 "\n"
1260 "If the coroutine is not done, this returns the stack where it is\n"
1261 "suspended. If the coroutine has completed successfully or was\n"
1262 "cancelled, this returns an empty list. If the coroutine was\n"
1263 "terminated by an exception, this returns the list of traceback\n"
1264 "frames.\n"
1265 "\n"
1266 "The frames are always ordered from oldest to newest.\n"
1267 "\n"
1268 "The optional limit gives the maximum number of frames to\n"
1269 "return; by default all available frames are returned. Its\n"
1270 "meaning differs depending on whether a stack or a traceback is\n"
1271 "returned: the newest frames of a stack are returned, but the\n"
1272 "oldest frames of a traceback are returned. (This matches the\n"
1273 "behavior of the traceback module.)\n"
1274 "\n"
1275 "For reasons beyond our control, only one stack frame is\n"
1276 "returned for a suspended coroutine.");
1277
1278 #define _ASYNCIO_TASK_GET_STACK_METHODDEF \
1279 {"get_stack", _PyCFunction_CAST(_asyncio_Task_get_stack), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__},
1280
1281 static PyObject *
1282 _asyncio_Task_get_stack_impl(TaskObj *self, PyTypeObject *cls,
1283 PyObject *limit);
1284
1285 static PyObject *
1286 _asyncio_Task_get_stack(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1287 {
1288 PyObject *return_value = NULL;
1289 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1290
1291 #define NUM_KEYWORDS 1
1292 static struct {
1293 PyGC_Head _this_is_not_used;
1294 PyObject_VAR_HEAD
1295 Py_hash_t ob_hash;
1296 PyObject *ob_item[NUM_KEYWORDS];
1297 } _kwtuple = {
1298 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1299 .ob_hash = -1,
1300 .ob_item = { &_Py_ID(limit), },
1301 };
1302 #undef NUM_KEYWORDS
1303 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1304
1305 #else // !Py_BUILD_CORE
1306 # define KWTUPLE NULL
1307 #endif // !Py_BUILD_CORE
1308
1309 static const char * const _keywords[] = {"limit", NULL};
1310 static _PyArg_Parser _parser = {
1311 .keywords = _keywords,
1312 .fname = "get_stack",
1313 .kwtuple = KWTUPLE,
1314 };
1315 #undef KWTUPLE
1316 PyObject *argsbuf[1];
1317 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1318 PyObject *limit = Py_None;
1319
1320 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1321 /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1322 if (!args) {
1323 goto exit;
1324 }
1325 if (!noptargs) {
1326 goto skip_optional_kwonly;
1327 }
1328 limit = args[0];
1329 skip_optional_kwonly:
1330 return_value = _asyncio_Task_get_stack_impl((TaskObj *)self, cls, limit);
1331
1332 exit:
1333 return return_value;
1334 }
1335
1336 PyDoc_STRVAR(_asyncio_Task_print_stack__doc__,
1337 "print_stack($self, /, *, limit=None, file=None)\n"
1338 "--\n"
1339 "\n"
1340 "Print the stack or traceback for this task\'s coroutine.\n"
1341 "\n"
1342 "This produces output similar to that of the traceback module,\n"
1343 "for the frames retrieved by get_stack(). The limit argument\n"
1344 "is passed to get_stack(). The file argument is an I/O stream\n"
1345 "to which the output is written; by default output is written\n"
1346 "to sys.stderr.");
1347
1348 #define _ASYNCIO_TASK_PRINT_STACK_METHODDEF \
1349 {"print_stack", _PyCFunction_CAST(_asyncio_Task_print_stack), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__},
1350
1351 static PyObject *
1352 _asyncio_Task_print_stack_impl(TaskObj *self, PyTypeObject *cls,
1353 PyObject *limit, PyObject *file);
1354
1355 static PyObject *
1356 _asyncio_Task_print_stack(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1357 {
1358 PyObject *return_value = NULL;
1359 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1360
1361 #define NUM_KEYWORDS 2
1362 static struct {
1363 PyGC_Head _this_is_not_used;
1364 PyObject_VAR_HEAD
1365 Py_hash_t ob_hash;
1366 PyObject *ob_item[NUM_KEYWORDS];
1367 } _kwtuple = {
1368 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1369 .ob_hash = -1,
1370 .ob_item = { &_Py_ID(limit), &_Py_ID(file), },
1371 };
1372 #undef NUM_KEYWORDS
1373 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1374
1375 #else // !Py_BUILD_CORE
1376 # define KWTUPLE NULL
1377 #endif // !Py_BUILD_CORE
1378
1379 static const char * const _keywords[] = {"limit", "file", NULL};
1380 static _PyArg_Parser _parser = {
1381 .keywords = _keywords,
1382 .fname = "print_stack",
1383 .kwtuple = KWTUPLE,
1384 };
1385 #undef KWTUPLE
1386 PyObject *argsbuf[2];
1387 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1388 PyObject *limit = Py_None;
1389 PyObject *file = Py_None;
1390
1391 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1392 /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1393 if (!args) {
1394 goto exit;
1395 }
1396 if (!noptargs) {
1397 goto skip_optional_kwonly;
1398 }
1399 if (args[0]) {
1400 limit = args[0];
1401 if (!--noptargs) {
1402 goto skip_optional_kwonly;
1403 }
1404 }
1405 file = args[1];
1406 skip_optional_kwonly:
1407 return_value = _asyncio_Task_print_stack_impl((TaskObj *)self, cls, limit, file);
1408
1409 exit:
1410 return return_value;
1411 }
1412
1413 PyDoc_STRVAR(_asyncio_Task_set_result__doc__,
1414 "set_result($self, result, /)\n"
1415 "--\n"
1416 "\n");
1417
1418 #define _ASYNCIO_TASK_SET_RESULT_METHODDEF \
1419 {"set_result", (PyCFunction)_asyncio_Task_set_result, METH_O, _asyncio_Task_set_result__doc__},
1420
1421 static PyObject *
1422 _asyncio_Task_set_result_impl(TaskObj *self, PyObject *result);
1423
1424 static PyObject *
1425 _asyncio_Task_set_result(PyObject *self, PyObject *result)
1426 {
1427 PyObject *return_value = NULL;
1428
1429 return_value = _asyncio_Task_set_result_impl((TaskObj *)self, result);
1430
1431 return return_value;
1432 }
1433
1434 PyDoc_STRVAR(_asyncio_Task_set_exception__doc__,
1435 "set_exception($self, exception, /)\n"
1436 "--\n"
1437 "\n");
1438
1439 #define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \
1440 {"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__},
1441
1442 static PyObject *
1443 _asyncio_Task_set_exception_impl(TaskObj *self, PyObject *exception);
1444
1445 static PyObject *
1446 _asyncio_Task_set_exception(PyObject *self, PyObject *exception)
1447 {
1448 PyObject *return_value = NULL;
1449
1450 return_value = _asyncio_Task_set_exception_impl((TaskObj *)self, exception);
1451
1452 return return_value;
1453 }
1454
1455 PyDoc_STRVAR(_asyncio_Task_get_coro__doc__,
1456 "get_coro($self, /)\n"
1457 "--\n"
1458 "\n");
1459
1460 #define _ASYNCIO_TASK_GET_CORO_METHODDEF \
1461 {"get_coro", (PyCFunction)_asyncio_Task_get_coro, METH_NOARGS, _asyncio_Task_get_coro__doc__},
1462
1463 static PyObject *
1464 _asyncio_Task_get_coro_impl(TaskObj *self);
1465
1466 static PyObject *
1467 _asyncio_Task_get_coro(PyObject *self, PyObject *Py_UNUSED(ignored))
1468 {
1469 PyObject *return_value = NULL;
1470
1471 Py_BEGIN_CRITICAL_SECTION(self);
1472 return_value = _asyncio_Task_get_coro_impl((TaskObj *)self);
1473 Py_END_CRITICAL_SECTION();
1474
1475 return return_value;
1476 }
1477
1478 PyDoc_STRVAR(_asyncio_Task_get_context__doc__,
1479 "get_context($self, /)\n"
1480 "--\n"
1481 "\n");
1482
1483 #define _ASYNCIO_TASK_GET_CONTEXT_METHODDEF \
1484 {"get_context", (PyCFunction)_asyncio_Task_get_context, METH_NOARGS, _asyncio_Task_get_context__doc__},
1485
1486 static PyObject *
1487 _asyncio_Task_get_context_impl(TaskObj *self);
1488
1489 static PyObject *
1490 _asyncio_Task_get_context(PyObject *self, PyObject *Py_UNUSED(ignored))
1491 {
1492 return _asyncio_Task_get_context_impl((TaskObj *)self);
1493 }
1494
1495 PyDoc_STRVAR(_asyncio_Task_get_name__doc__,
1496 "get_name($self, /)\n"
1497 "--\n"
1498 "\n");
1499
1500 #define _ASYNCIO_TASK_GET_NAME_METHODDEF \
1501 {"get_name", (PyCFunction)_asyncio_Task_get_name, METH_NOARGS, _asyncio_Task_get_name__doc__},
1502
1503 static PyObject *
1504 _asyncio_Task_get_name_impl(TaskObj *self);
1505
1506 static PyObject *
1507 _asyncio_Task_get_name(PyObject *self, PyObject *Py_UNUSED(ignored))
1508 {
1509 PyObject *return_value = NULL;
1510
1511 Py_BEGIN_CRITICAL_SECTION(self);
1512 return_value = _asyncio_Task_get_name_impl((TaskObj *)self);
1513 Py_END_CRITICAL_SECTION();
1514
1515 return return_value;
1516 }
1517
1518 PyDoc_STRVAR(_asyncio_Task_set_name__doc__,
1519 "set_name($self, value, /)\n"
1520 "--\n"
1521 "\n");
1522
1523 #define _ASYNCIO_TASK_SET_NAME_METHODDEF \
1524 {"set_name", (PyCFunction)_asyncio_Task_set_name, METH_O, _asyncio_Task_set_name__doc__},
1525
1526 static PyObject *
1527 _asyncio_Task_set_name_impl(TaskObj *self, PyObject *value);
1528
1529 static PyObject *
1530 _asyncio_Task_set_name(PyObject *self, PyObject *value)
1531 {
1532 PyObject *return_value = NULL;
1533
1534 Py_BEGIN_CRITICAL_SECTION(self);
1535 return_value = _asyncio_Task_set_name_impl((TaskObj *)self, value);
1536 Py_END_CRITICAL_SECTION();
1537
1538 return return_value;
1539 }
1540
1541 PyDoc_STRVAR(_asyncio__get_running_loop__doc__,
1542 "_get_running_loop($module, /)\n"
1543 "--\n"
1544 "\n"
1545 "Return the running event loop or None.\n"
1546 "\n"
1547 "This is a low-level function intended to be used by event loops.\n"
1548 "This function is thread-specific.");
1549
1550 #define _ASYNCIO__GET_RUNNING_LOOP_METHODDEF \
1551 {"_get_running_loop", (PyCFunction)_asyncio__get_running_loop, METH_NOARGS, _asyncio__get_running_loop__doc__},
1552
1553 static PyObject *
1554 _asyncio__get_running_loop_impl(PyObject *module);
1555
1556 static PyObject *
1557 _asyncio__get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
1558 {
1559 return _asyncio__get_running_loop_impl(module);
1560 }
1561
1562 PyDoc_STRVAR(_asyncio__set_running_loop__doc__,
1563 "_set_running_loop($module, loop, /)\n"
1564 "--\n"
1565 "\n"
1566 "Set the running event loop.\n"
1567 "\n"
1568 "This is a low-level function intended to be used by event loops.\n"
1569 "This function is thread-specific.");
1570
1571 #define _ASYNCIO__SET_RUNNING_LOOP_METHODDEF \
1572 {"_set_running_loop", (PyCFunction)_asyncio__set_running_loop, METH_O, _asyncio__set_running_loop__doc__},
1573
1574 PyDoc_STRVAR(_asyncio_get_event_loop__doc__,
1575 "get_event_loop($module, /)\n"
1576 "--\n"
1577 "\n"
1578 "Return an asyncio event loop.\n"
1579 "\n"
1580 "When called from a coroutine or a callback (e.g. scheduled with\n"
1581 "call_soon or similar API), this function will always return the\n"
1582 "running event loop.\n"
1583 "\n"
1584 "If there is no running event loop set, the function will return\n"
1585 "the result of `get_event_loop_policy().get_event_loop()` call.");
1586
1587 #define _ASYNCIO_GET_EVENT_LOOP_METHODDEF \
1588 {"get_event_loop", (PyCFunction)_asyncio_get_event_loop, METH_NOARGS, _asyncio_get_event_loop__doc__},
1589
1590 static PyObject *
1591 _asyncio_get_event_loop_impl(PyObject *module);
1592
1593 static PyObject *
1594 _asyncio_get_event_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
1595 {
1596 return _asyncio_get_event_loop_impl(module);
1597 }
1598
1599 PyDoc_STRVAR(_asyncio_get_running_loop__doc__,
1600 "get_running_loop($module, /)\n"
1601 "--\n"
1602 "\n"
1603 "Return the running event loop. Raise a RuntimeError if there is none.\n"
1604 "\n"
1605 "This function is thread-specific.");
1606
1607 #define _ASYNCIO_GET_RUNNING_LOOP_METHODDEF \
1608 {"get_running_loop", (PyCFunction)_asyncio_get_running_loop, METH_NOARGS, _asyncio_get_running_loop__doc__},
1609
1610 static PyObject *
1611 _asyncio_get_running_loop_impl(PyObject *module);
1612
1613 static PyObject *
1614 _asyncio_get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
1615 {
1616 return _asyncio_get_running_loop_impl(module);
1617 }
1618
1619 PyDoc_STRVAR(_asyncio__register_task__doc__,
1620 "_register_task($module, /, task)\n"
1621 "--\n"
1622 "\n"
1623 "Register a new task in asyncio as executed by loop.\n"
1624 "\n"
1625 "Returns None.");
1626
1627 #define _ASYNCIO__REGISTER_TASK_METHODDEF \
1628 {"_register_task", _PyCFunction_CAST(_asyncio__register_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__},
1629
1630 static PyObject *
1631 _asyncio__register_task_impl(PyObject *module, PyObject *task);
1632
1633 static PyObject *
1634 _asyncio__register_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1635 {
1636 PyObject *return_value = NULL;
1637 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1638
1639 #define NUM_KEYWORDS 1
1640 static struct {
1641 PyGC_Head _this_is_not_used;
1642 PyObject_VAR_HEAD
1643 Py_hash_t ob_hash;
1644 PyObject *ob_item[NUM_KEYWORDS];
1645 } _kwtuple = {
1646 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1647 .ob_hash = -1,
1648 .ob_item = { &_Py_ID(task), },
1649 };
1650 #undef NUM_KEYWORDS
1651 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1652
1653 #else // !Py_BUILD_CORE
1654 # define KWTUPLE NULL
1655 #endif // !Py_BUILD_CORE
1656
1657 static const char * const _keywords[] = {"task", NULL};
1658 static _PyArg_Parser _parser = {
1659 .keywords = _keywords,
1660 .fname = "_register_task",
1661 .kwtuple = KWTUPLE,
1662 };
1663 #undef KWTUPLE
1664 PyObject *argsbuf[1];
1665 PyObject *task;
1666
1667 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1668 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1669 if (!args) {
1670 goto exit;
1671 }
1672 task = args[0];
1673 return_value = _asyncio__register_task_impl(module, task);
1674
1675 exit:
1676 return return_value;
1677 }
1678
1679 PyDoc_STRVAR(_asyncio__register_eager_task__doc__,
1680 "_register_eager_task($module, /, task)\n"
1681 "--\n"
1682 "\n"
1683 "Register a new task in asyncio as executed by loop.\n"
1684 "\n"
1685 "Returns None.");
1686
1687 #define _ASYNCIO__REGISTER_EAGER_TASK_METHODDEF \
1688 {"_register_eager_task", _PyCFunction_CAST(_asyncio__register_eager_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__register_eager_task__doc__},
1689
1690 static PyObject *
1691 _asyncio__register_eager_task_impl(PyObject *module, PyObject *task);
1692
1693 static PyObject *
1694 _asyncio__register_eager_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1695 {
1696 PyObject *return_value = NULL;
1697 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1698
1699 #define NUM_KEYWORDS 1
1700 static struct {
1701 PyGC_Head _this_is_not_used;
1702 PyObject_VAR_HEAD
1703 Py_hash_t ob_hash;
1704 PyObject *ob_item[NUM_KEYWORDS];
1705 } _kwtuple = {
1706 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1707 .ob_hash = -1,
1708 .ob_item = { &_Py_ID(task), },
1709 };
1710 #undef NUM_KEYWORDS
1711 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1712
1713 #else // !Py_BUILD_CORE
1714 # define KWTUPLE NULL
1715 #endif // !Py_BUILD_CORE
1716
1717 static const char * const _keywords[] = {"task", NULL};
1718 static _PyArg_Parser _parser = {
1719 .keywords = _keywords,
1720 .fname = "_register_eager_task",
1721 .kwtuple = KWTUPLE,
1722 };
1723 #undef KWTUPLE
1724 PyObject *argsbuf[1];
1725 PyObject *task;
1726
1727 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1728 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1729 if (!args) {
1730 goto exit;
1731 }
1732 task = args[0];
1733 return_value = _asyncio__register_eager_task_impl(module, task);
1734
1735 exit:
1736 return return_value;
1737 }
1738
1739 PyDoc_STRVAR(_asyncio__unregister_task__doc__,
1740 "_unregister_task($module, /, task)\n"
1741 "--\n"
1742 "\n"
1743 "Unregister a task.\n"
1744 "\n"
1745 "Returns None.");
1746
1747 #define _ASYNCIO__UNREGISTER_TASK_METHODDEF \
1748 {"_unregister_task", _PyCFunction_CAST(_asyncio__unregister_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__},
1749
1750 static PyObject *
1751 _asyncio__unregister_task_impl(PyObject *module, PyObject *task);
1752
1753 static PyObject *
1754 _asyncio__unregister_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1755 {
1756 PyObject *return_value = NULL;
1757 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1758
1759 #define NUM_KEYWORDS 1
1760 static struct {
1761 PyGC_Head _this_is_not_used;
1762 PyObject_VAR_HEAD
1763 Py_hash_t ob_hash;
1764 PyObject *ob_item[NUM_KEYWORDS];
1765 } _kwtuple = {
1766 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1767 .ob_hash = -1,
1768 .ob_item = { &_Py_ID(task), },
1769 };
1770 #undef NUM_KEYWORDS
1771 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1772
1773 #else // !Py_BUILD_CORE
1774 # define KWTUPLE NULL
1775 #endif // !Py_BUILD_CORE
1776
1777 static const char * const _keywords[] = {"task", NULL};
1778 static _PyArg_Parser _parser = {
1779 .keywords = _keywords,
1780 .fname = "_unregister_task",
1781 .kwtuple = KWTUPLE,
1782 };
1783 #undef KWTUPLE
1784 PyObject *argsbuf[1];
1785 PyObject *task;
1786
1787 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1788 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1789 if (!args) {
1790 goto exit;
1791 }
1792 task = args[0];
1793 return_value = _asyncio__unregister_task_impl(module, task);
1794
1795 exit:
1796 return return_value;
1797 }
1798
1799 PyDoc_STRVAR(_asyncio__unregister_eager_task__doc__,
1800 "_unregister_eager_task($module, /, task)\n"
1801 "--\n"
1802 "\n"
1803 "Unregister a task.\n"
1804 "\n"
1805 "Returns None.");
1806
1807 #define _ASYNCIO__UNREGISTER_EAGER_TASK_METHODDEF \
1808 {"_unregister_eager_task", _PyCFunction_CAST(_asyncio__unregister_eager_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_eager_task__doc__},
1809
1810 static PyObject *
1811 _asyncio__unregister_eager_task_impl(PyObject *module, PyObject *task);
1812
1813 static PyObject *
1814 _asyncio__unregister_eager_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1815 {
1816 PyObject *return_value = NULL;
1817 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1818
1819 #define NUM_KEYWORDS 1
1820 static struct {
1821 PyGC_Head _this_is_not_used;
1822 PyObject_VAR_HEAD
1823 Py_hash_t ob_hash;
1824 PyObject *ob_item[NUM_KEYWORDS];
1825 } _kwtuple = {
1826 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1827 .ob_hash = -1,
1828 .ob_item = { &_Py_ID(task), },
1829 };
1830 #undef NUM_KEYWORDS
1831 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1832
1833 #else // !Py_BUILD_CORE
1834 # define KWTUPLE NULL
1835 #endif // !Py_BUILD_CORE
1836
1837 static const char * const _keywords[] = {"task", NULL};
1838 static _PyArg_Parser _parser = {
1839 .keywords = _keywords,
1840 .fname = "_unregister_eager_task",
1841 .kwtuple = KWTUPLE,
1842 };
1843 #undef KWTUPLE
1844 PyObject *argsbuf[1];
1845 PyObject *task;
1846
1847 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1848 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1849 if (!args) {
1850 goto exit;
1851 }
1852 task = args[0];
1853 return_value = _asyncio__unregister_eager_task_impl(module, task);
1854
1855 exit:
1856 return return_value;
1857 }
1858
1859 PyDoc_STRVAR(_asyncio__enter_task__doc__,
1860 "_enter_task($module, /, loop, task)\n"
1861 "--\n"
1862 "\n"
1863 "Enter into task execution or resume suspended task.\n"
1864 "\n"
1865 "Task belongs to loop.\n"
1866 "\n"
1867 "Returns None.");
1868
1869 #define _ASYNCIO__ENTER_TASK_METHODDEF \
1870 {"_enter_task", _PyCFunction_CAST(_asyncio__enter_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__},
1871
1872 static PyObject *
1873 _asyncio__enter_task_impl(PyObject *module, PyObject *loop, PyObject *task);
1874
1875 static PyObject *
1876 _asyncio__enter_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1877 {
1878 PyObject *return_value = NULL;
1879 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1880
1881 #define NUM_KEYWORDS 2
1882 static struct {
1883 PyGC_Head _this_is_not_used;
1884 PyObject_VAR_HEAD
1885 Py_hash_t ob_hash;
1886 PyObject *ob_item[NUM_KEYWORDS];
1887 } _kwtuple = {
1888 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1889 .ob_hash = -1,
1890 .ob_item = { &_Py_ID(loop), &_Py_ID(task), },
1891 };
1892 #undef NUM_KEYWORDS
1893 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1894
1895 #else // !Py_BUILD_CORE
1896 # define KWTUPLE NULL
1897 #endif // !Py_BUILD_CORE
1898
1899 static const char * const _keywords[] = {"loop", "task", NULL};
1900 static _PyArg_Parser _parser = {
1901 .keywords = _keywords,
1902 .fname = "_enter_task",
1903 .kwtuple = KWTUPLE,
1904 };
1905 #undef KWTUPLE
1906 PyObject *argsbuf[2];
1907 PyObject *loop;
1908 PyObject *task;
1909
1910 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1911 /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1912 if (!args) {
1913 goto exit;
1914 }
1915 loop = args[0];
1916 task = args[1];
1917 return_value = _asyncio__enter_task_impl(module, loop, task);
1918
1919 exit:
1920 return return_value;
1921 }
1922
1923 PyDoc_STRVAR(_asyncio__leave_task__doc__,
1924 "_leave_task($module, /, loop, task)\n"
1925 "--\n"
1926 "\n"
1927 "Leave task execution or suspend a task.\n"
1928 "\n"
1929 "Task belongs to loop.\n"
1930 "\n"
1931 "Returns None.");
1932
1933 #define _ASYNCIO__LEAVE_TASK_METHODDEF \
1934 {"_leave_task", _PyCFunction_CAST(_asyncio__leave_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__},
1935
1936 static PyObject *
1937 _asyncio__leave_task_impl(PyObject *module, PyObject *loop, PyObject *task);
1938
1939 static PyObject *
1940 _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1941 {
1942 PyObject *return_value = NULL;
1943 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1944
1945 #define NUM_KEYWORDS 2
1946 static struct {
1947 PyGC_Head _this_is_not_used;
1948 PyObject_VAR_HEAD
1949 Py_hash_t ob_hash;
1950 PyObject *ob_item[NUM_KEYWORDS];
1951 } _kwtuple = {
1952 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1953 .ob_hash = -1,
1954 .ob_item = { &_Py_ID(loop), &_Py_ID(task), },
1955 };
1956 #undef NUM_KEYWORDS
1957 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1958
1959 #else // !Py_BUILD_CORE
1960 # define KWTUPLE NULL
1961 #endif // !Py_BUILD_CORE
1962
1963 static const char * const _keywords[] = {"loop", "task", NULL};
1964 static _PyArg_Parser _parser = {
1965 .keywords = _keywords,
1966 .fname = "_leave_task",
1967 .kwtuple = KWTUPLE,
1968 };
1969 #undef KWTUPLE
1970 PyObject *argsbuf[2];
1971 PyObject *loop;
1972 PyObject *task;
1973
1974 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1975 /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1976 if (!args) {
1977 goto exit;
1978 }
1979 loop = args[0];
1980 task = args[1];
1981 return_value = _asyncio__leave_task_impl(module, loop, task);
1982
1983 exit:
1984 return return_value;
1985 }
1986
1987 PyDoc_STRVAR(_asyncio__swap_current_task__doc__,
1988 "_swap_current_task($module, /, loop, task)\n"
1989 "--\n"
1990 "\n"
1991 "Temporarily swap in the supplied task and return the original one (or None).\n"
1992 "\n"
1993 "This is intended for use during eager coroutine execution.");
1994
1995 #define _ASYNCIO__SWAP_CURRENT_TASK_METHODDEF \
1996 {"_swap_current_task", _PyCFunction_CAST(_asyncio__swap_current_task), METH_FASTCALL|METH_KEYWORDS, _asyncio__swap_current_task__doc__},
1997
1998 static PyObject *
1999 _asyncio__swap_current_task_impl(PyObject *module, PyObject *loop,
2000 PyObject *task);
2001
2002 static PyObject *
2003 _asyncio__swap_current_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
2004 {
2005 PyObject *return_value = NULL;
2006 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
2007
2008 #define NUM_KEYWORDS 2
2009 static struct {
2010 PyGC_Head _this_is_not_used;
2011 PyObject_VAR_HEAD
2012 Py_hash_t ob_hash;
2013 PyObject *ob_item[NUM_KEYWORDS];
2014 } _kwtuple = {
2015 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
2016 .ob_hash = -1,
2017 .ob_item = { &_Py_ID(loop), &_Py_ID(task), },
2018 };
2019 #undef NUM_KEYWORDS
2020 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
2021
2022 #else // !Py_BUILD_CORE
2023 # define KWTUPLE NULL
2024 #endif // !Py_BUILD_CORE
2025
2026 static const char * const _keywords[] = {"loop", "task", NULL};
2027 static _PyArg_Parser _parser = {
2028 .keywords = _keywords,
2029 .fname = "_swap_current_task",
2030 .kwtuple = KWTUPLE,
2031 };
2032 #undef KWTUPLE
2033 PyObject *argsbuf[2];
2034 PyObject *loop;
2035 PyObject *task;
2036
2037 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
2038 /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
2039 if (!args) {
2040 goto exit;
2041 }
2042 loop = args[0];
2043 task = args[1];
2044 return_value = _asyncio__swap_current_task_impl(module, loop, task);
2045
2046 exit:
2047 return return_value;
2048 }
2049
2050 PyDoc_STRVAR(_asyncio_current_task__doc__,
2051 "current_task($module, /, loop=None)\n"
2052 "--\n"
2053 "\n"
2054 "Return a currently executed task.");
2055
2056 #define _ASYNCIO_CURRENT_TASK_METHODDEF \
2057 {"current_task", _PyCFunction_CAST(_asyncio_current_task), METH_FASTCALL|METH_KEYWORDS, _asyncio_current_task__doc__},
2058
2059 static PyObject *
2060 _asyncio_current_task_impl(PyObject *module, PyObject *loop);
2061
2062 static PyObject *
2063 _asyncio_current_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
2064 {
2065 PyObject *return_value = NULL;
2066 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
2067
2068 #define NUM_KEYWORDS 1
2069 static struct {
2070 PyGC_Head _this_is_not_used;
2071 PyObject_VAR_HEAD
2072 Py_hash_t ob_hash;
2073 PyObject *ob_item[NUM_KEYWORDS];
2074 } _kwtuple = {
2075 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
2076 .ob_hash = -1,
2077 .ob_item = { &_Py_ID(loop), },
2078 };
2079 #undef NUM_KEYWORDS
2080 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
2081
2082 #else // !Py_BUILD_CORE
2083 # define KWTUPLE NULL
2084 #endif // !Py_BUILD_CORE
2085
2086 static const char * const _keywords[] = {"loop", NULL};
2087 static _PyArg_Parser _parser = {
2088 .keywords = _keywords,
2089 .fname = "current_task",
2090 .kwtuple = KWTUPLE,
2091 };
2092 #undef KWTUPLE
2093 PyObject *argsbuf[1];
2094 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
2095 PyObject *loop = Py_None;
2096
2097 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
2098 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
2099 if (!args) {
2100 goto exit;
2101 }
2102 if (!noptargs) {
2103 goto skip_optional_pos;
2104 }
2105 loop = args[0];
2106 skip_optional_pos:
2107 return_value = _asyncio_current_task_impl(module, loop);
2108
2109 exit:
2110 return return_value;
2111 }
2112
2113 PyDoc_STRVAR(_asyncio_all_tasks__doc__,
2114 "all_tasks($module, /, loop=None)\n"
2115 "--\n"
2116 "\n"
2117 "Return a set of all tasks for the loop.");
2118
2119 #define _ASYNCIO_ALL_TASKS_METHODDEF \
2120 {"all_tasks", _PyCFunction_CAST(_asyncio_all_tasks), METH_FASTCALL|METH_KEYWORDS, _asyncio_all_tasks__doc__},
2121
2122 static PyObject *
2123 _asyncio_all_tasks_impl(PyObject *module, PyObject *loop);
2124
2125 static PyObject *
2126 _asyncio_all_tasks(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
2127 {
2128 PyObject *return_value = NULL;
2129 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
2130
2131 #define NUM_KEYWORDS 1
2132 static struct {
2133 PyGC_Head _this_is_not_used;
2134 PyObject_VAR_HEAD
2135 Py_hash_t ob_hash;
2136 PyObject *ob_item[NUM_KEYWORDS];
2137 } _kwtuple = {
2138 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
2139 .ob_hash = -1,
2140 .ob_item = { &_Py_ID(loop), },
2141 };
2142 #undef NUM_KEYWORDS
2143 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
2144
2145 #else // !Py_BUILD_CORE
2146 # define KWTUPLE NULL
2147 #endif // !Py_BUILD_CORE
2148
2149 static const char * const _keywords[] = {"loop", NULL};
2150 static _PyArg_Parser _parser = {
2151 .keywords = _keywords,
2152 .fname = "all_tasks",
2153 .kwtuple = KWTUPLE,
2154 };
2155 #undef KWTUPLE
2156 PyObject *argsbuf[1];
2157 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
2158 PyObject *loop = Py_None;
2159
2160 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
2161 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
2162 if (!args) {
2163 goto exit;
2164 }
2165 if (!noptargs) {
2166 goto skip_optional_pos;
2167 }
2168 loop = args[0];
2169 skip_optional_pos:
2170 return_value = _asyncio_all_tasks_impl(module, loop);
2171
2172 exit:
2173 return return_value;
2174 }
2175
2176 PyDoc_STRVAR(_asyncio_future_add_to_awaited_by__doc__,
2177 "future_add_to_awaited_by($module, fut, waiter, /)\n"
2178 "--\n"
2179 "\n"
2180 "Record that `fut` is awaited on by `waiter`.");
2181
2182 #define _ASYNCIO_FUTURE_ADD_TO_AWAITED_BY_METHODDEF \
2183 {"future_add_to_awaited_by", _PyCFunction_CAST(_asyncio_future_add_to_awaited_by), METH_FASTCALL, _asyncio_future_add_to_awaited_by__doc__},
2184
2185 static PyObject *
2186 _asyncio_future_add_to_awaited_by_impl(PyObject *module, PyObject *fut,
2187 PyObject *waiter);
2188
2189 static PyObject *
2190 _asyncio_future_add_to_awaited_by(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2191 {
2192 PyObject *return_value = NULL;
2193 PyObject *fut;
2194 PyObject *waiter;
2195
2196 if (!_PyArg_CheckPositional("future_add_to_awaited_by", nargs, 2, 2)) {
2197 goto exit;
2198 }
2199 fut = args[0];
2200 waiter = args[1];
2201 return_value = _asyncio_future_add_to_awaited_by_impl(module, fut, waiter);
2202
2203 exit:
2204 return return_value;
2205 }
2206
2207 PyDoc_STRVAR(_asyncio_future_discard_from_awaited_by__doc__,
2208 "future_discard_from_awaited_by($module, fut, waiter, /)\n"
2209 "--\n"
2210 "\n");
2211
2212 #define _ASYNCIO_FUTURE_DISCARD_FROM_AWAITED_BY_METHODDEF \
2213 {"future_discard_from_awaited_by", _PyCFunction_CAST(_asyncio_future_discard_from_awaited_by), METH_FASTCALL, _asyncio_future_discard_from_awaited_by__doc__},
2214
2215 static PyObject *
2216 _asyncio_future_discard_from_awaited_by_impl(PyObject *module, PyObject *fut,
2217 PyObject *waiter);
2218
2219 static PyObject *
2220 _asyncio_future_discard_from_awaited_by(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2221 {
2222 PyObject *return_value = NULL;
2223 PyObject *fut;
2224 PyObject *waiter;
2225
2226 if (!_PyArg_CheckPositional("future_discard_from_awaited_by", nargs, 2, 2)) {
2227 goto exit;
2228 }
2229 fut = args[0];
2230 waiter = args[1];
2231 return_value = _asyncio_future_discard_from_awaited_by_impl(module, fut, waiter);
2232
2233 exit:
2234 return return_value;
2235 }
2236 /*[clinic end generated code: output=32996fb47c48245b input=a9049054013a1b77]*/