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