Coverage Report

Created: 2026-08-28 06:28

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