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