blob: 860b57f9ee38a07376b5a85f394850e5b1beb992 [file] [log] [blame]
Yury Selivanova0c1ba62016-10-28 12:52:37 -04001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_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
22static int
23_asyncio_Future___init___impl(FutureObj *self, PyObject *loop);
24
25static 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 = {"|$O:Future", _keywords, 0};
Serhiy Storchakabca49392017-09-03 08:10:14 +030031 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -040032
33 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
34 &loop)) {
35 goto exit;
36 }
37 return_value = _asyncio_Future___init___impl((FutureObj *)self, loop);
38
39exit:
40 return return_value;
41}
42
43PyDoc_STRVAR(_asyncio_Future_result__doc__,
44"result($self, /)\n"
45"--\n"
46"\n"
47"Return the result this future represents.\n"
48"\n"
49"If the future has been cancelled, raises CancelledError. If the\n"
50"future\'s result isn\'t yet available, raises InvalidStateError. If\n"
51"the future is done and has an exception set, this exception is raised.");
52
53#define _ASYNCIO_FUTURE_RESULT_METHODDEF \
54 {"result", (PyCFunction)_asyncio_Future_result, METH_NOARGS, _asyncio_Future_result__doc__},
55
56static PyObject *
57_asyncio_Future_result_impl(FutureObj *self);
58
59static PyObject *
60_asyncio_Future_result(FutureObj *self, PyObject *Py_UNUSED(ignored))
61{
62 return _asyncio_Future_result_impl(self);
63}
64
65PyDoc_STRVAR(_asyncio_Future_exception__doc__,
66"exception($self, /)\n"
67"--\n"
68"\n"
69"Return the exception that was set on this future.\n"
70"\n"
71"The exception (or None if no exception was set) is returned only if\n"
72"the future is done. If the future has been cancelled, raises\n"
73"CancelledError. If the future isn\'t done yet, raises\n"
74"InvalidStateError.");
75
76#define _ASYNCIO_FUTURE_EXCEPTION_METHODDEF \
77 {"exception", (PyCFunction)_asyncio_Future_exception, METH_NOARGS, _asyncio_Future_exception__doc__},
78
79static PyObject *
80_asyncio_Future_exception_impl(FutureObj *self);
81
82static PyObject *
83_asyncio_Future_exception(FutureObj *self, PyObject *Py_UNUSED(ignored))
84{
85 return _asyncio_Future_exception_impl(self);
86}
87
88PyDoc_STRVAR(_asyncio_Future_set_result__doc__,
Yury Selivanov0cf16f92017-12-25 10:48:15 -050089"set_result($self, result, /)\n"
Yury Selivanova0c1ba62016-10-28 12:52:37 -040090"--\n"
91"\n"
92"Mark the future done and set its result.\n"
93"\n"
94"If the future is already done when this method is called, raises\n"
95"InvalidStateError.");
96
97#define _ASYNCIO_FUTURE_SET_RESULT_METHODDEF \
98 {"set_result", (PyCFunction)_asyncio_Future_set_result, METH_O, _asyncio_Future_set_result__doc__},
99
100PyDoc_STRVAR(_asyncio_Future_set_exception__doc__,
101"set_exception($self, exception, /)\n"
102"--\n"
103"\n"
104"Mark the future done and set an exception.\n"
105"\n"
106"If the future is already done when this method is called, raises\n"
107"InvalidStateError.");
108
109#define _ASYNCIO_FUTURE_SET_EXCEPTION_METHODDEF \
110 {"set_exception", (PyCFunction)_asyncio_Future_set_exception, METH_O, _asyncio_Future_set_exception__doc__},
111
112PyDoc_STRVAR(_asyncio_Future_add_done_callback__doc__,
Yury Selivanovf23746a2018-01-22 19:11:18 -0500113"add_done_callback($self, fn, /, *, context=None)\n"
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400114"--\n"
115"\n"
116"Add a callback to be run when the future becomes done.\n"
117"\n"
118"The callback is called with a single argument - the future object. If\n"
119"the future is already done when this is called, the callback is\n"
120"scheduled with call_soon.");
121
122#define _ASYNCIO_FUTURE_ADD_DONE_CALLBACK_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200123 {"add_done_callback", (PyCFunction)(void(*)(void))_asyncio_Future_add_done_callback, METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_add_done_callback__doc__},
Yury Selivanovf23746a2018-01-22 19:11:18 -0500124
125static PyObject *
126_asyncio_Future_add_done_callback_impl(FutureObj *self, PyObject *fn,
127 PyObject *context);
128
129static PyObject *
130_asyncio_Future_add_done_callback(FutureObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
131{
132 PyObject *return_value = NULL;
133 static const char * const _keywords[] = {"", "context", NULL};
134 static _PyArg_Parser _parser = {"O|$O:add_done_callback", _keywords, 0};
135 PyObject *fn;
136 PyObject *context = NULL;
137
138 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
139 &fn, &context)) {
140 goto exit;
141 }
142 return_value = _asyncio_Future_add_done_callback_impl(self, fn, context);
143
144exit:
145 return return_value;
146}
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400147
148PyDoc_STRVAR(_asyncio_Future_remove_done_callback__doc__,
149"remove_done_callback($self, fn, /)\n"
150"--\n"
151"\n"
152"Remove all instances of a callback from the \"call when done\" list.\n"
153"\n"
154"Returns the number of callbacks removed.");
155
156#define _ASYNCIO_FUTURE_REMOVE_DONE_CALLBACK_METHODDEF \
157 {"remove_done_callback", (PyCFunction)_asyncio_Future_remove_done_callback, METH_O, _asyncio_Future_remove_done_callback__doc__},
158
159PyDoc_STRVAR(_asyncio_Future_cancel__doc__,
160"cancel($self, /)\n"
161"--\n"
162"\n"
163"Cancel the future and schedule callbacks.\n"
164"\n"
165"If the future is already done or cancelled, return False. Otherwise,\n"
166"change the future\'s state to cancelled, schedule the callbacks and\n"
167"return True.");
168
169#define _ASYNCIO_FUTURE_CANCEL_METHODDEF \
170 {"cancel", (PyCFunction)_asyncio_Future_cancel, METH_NOARGS, _asyncio_Future_cancel__doc__},
171
172static PyObject *
173_asyncio_Future_cancel_impl(FutureObj *self);
174
175static PyObject *
176_asyncio_Future_cancel(FutureObj *self, PyObject *Py_UNUSED(ignored))
177{
178 return _asyncio_Future_cancel_impl(self);
179}
180
181PyDoc_STRVAR(_asyncio_Future_cancelled__doc__,
182"cancelled($self, /)\n"
183"--\n"
184"\n"
185"Return True if the future was cancelled.");
186
187#define _ASYNCIO_FUTURE_CANCELLED_METHODDEF \
188 {"cancelled", (PyCFunction)_asyncio_Future_cancelled, METH_NOARGS, _asyncio_Future_cancelled__doc__},
189
190static PyObject *
191_asyncio_Future_cancelled_impl(FutureObj *self);
192
193static PyObject *
194_asyncio_Future_cancelled(FutureObj *self, PyObject *Py_UNUSED(ignored))
195{
196 return _asyncio_Future_cancelled_impl(self);
197}
198
199PyDoc_STRVAR(_asyncio_Future_done__doc__,
200"done($self, /)\n"
201"--\n"
202"\n"
203"Return True if the future is done.\n"
204"\n"
205"Done means either that a result / exception are available, or that the\n"
206"future was cancelled.");
207
208#define _ASYNCIO_FUTURE_DONE_METHODDEF \
209 {"done", (PyCFunction)_asyncio_Future_done, METH_NOARGS, _asyncio_Future_done__doc__},
210
211static PyObject *
212_asyncio_Future_done_impl(FutureObj *self);
213
214static PyObject *
215_asyncio_Future_done(FutureObj *self, PyObject *Py_UNUSED(ignored))
216{
217 return _asyncio_Future_done_impl(self);
218}
219
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500220PyDoc_STRVAR(_asyncio_Future_get_loop__doc__,
221"get_loop($self, /)\n"
222"--\n"
223"\n"
224"Return the event loop the Future is bound to.");
225
226#define _ASYNCIO_FUTURE_GET_LOOP_METHODDEF \
227 {"get_loop", (PyCFunction)_asyncio_Future_get_loop, METH_NOARGS, _asyncio_Future_get_loop__doc__},
228
229static PyObject *
230_asyncio_Future_get_loop_impl(FutureObj *self);
231
232static PyObject *
233_asyncio_Future_get_loop(FutureObj *self, PyObject *Py_UNUSED(ignored))
234{
235 return _asyncio_Future_get_loop_impl(self);
236}
237
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400238PyDoc_STRVAR(_asyncio_Future__repr_info__doc__,
239"_repr_info($self, /)\n"
240"--\n"
241"\n");
242
243#define _ASYNCIO_FUTURE__REPR_INFO_METHODDEF \
244 {"_repr_info", (PyCFunction)_asyncio_Future__repr_info, METH_NOARGS, _asyncio_Future__repr_info__doc__},
245
246static PyObject *
247_asyncio_Future__repr_info_impl(FutureObj *self);
248
249static PyObject *
250_asyncio_Future__repr_info(FutureObj *self, PyObject *Py_UNUSED(ignored))
251{
252 return _asyncio_Future__repr_info_impl(self);
253}
254
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400255PyDoc_STRVAR(_asyncio_Task___init____doc__,
Alex Grönholmcca4eec2018-08-09 00:06:47 +0300256"Task(coro, *, loop=None, name=None)\n"
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400257"--\n"
258"\n"
259"A coroutine wrapped in a Future.");
260
261static int
Alex Grönholmcca4eec2018-08-09 00:06:47 +0300262_asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop,
263 PyObject *name);
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400264
265static int
266_asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs)
267{
268 int return_value = -1;
Alex Grönholmcca4eec2018-08-09 00:06:47 +0300269 static const char * const _keywords[] = {"coro", "loop", "name", NULL};
270 static _PyArg_Parser _parser = {"O|$OO:Task", _keywords, 0};
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400271 PyObject *coro;
Serhiy Storchakabca49392017-09-03 08:10:14 +0300272 PyObject *loop = Py_None;
Alex Grönholmcca4eec2018-08-09 00:06:47 +0300273 PyObject *name = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400274
275 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
Alex Grönholmcca4eec2018-08-09 00:06:47 +0300276 &coro, &loop, &name)) {
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400277 goto exit;
278 }
Alex Grönholmcca4eec2018-08-09 00:06:47 +0300279 return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop, name);
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400280
281exit:
282 return return_value;
283}
284
285PyDoc_STRVAR(_asyncio_Task_current_task__doc__,
286"current_task($type, /, loop=None)\n"
287"--\n"
288"\n"
289"Return the currently running task in an event loop or None.\n"
290"\n"
291"By default the current task for the current event loop is returned.\n"
292"\n"
293"None is returned when called not in the context of a Task.");
294
295#define _ASYNCIO_TASK_CURRENT_TASK_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200296 {"current_task", (PyCFunction)(void(*)(void))_asyncio_Task_current_task, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, _asyncio_Task_current_task__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400297
298static PyObject *
299_asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop);
300
301static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200302_asyncio_Task_current_task(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400303{
304 PyObject *return_value = NULL;
305 static const char * const _keywords[] = {"loop", NULL};
306 static _PyArg_Parser _parser = {"|O:current_task", _keywords, 0};
Yury Selivanov8d26aa92017-03-02 22:16:33 -0500307 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400308
Victor Stinner3e1fad62017-01-17 01:29:01 +0100309 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400310 &loop)) {
311 goto exit;
312 }
313 return_value = _asyncio_Task_current_task_impl(type, loop);
314
315exit:
316 return return_value;
317}
318
319PyDoc_STRVAR(_asyncio_Task_all_tasks__doc__,
320"all_tasks($type, /, loop=None)\n"
321"--\n"
322"\n"
323"Return a set of all tasks for an event loop.\n"
324"\n"
325"By default all tasks for the current event loop are returned.");
326
327#define _ASYNCIO_TASK_ALL_TASKS_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200328 {"all_tasks", (PyCFunction)(void(*)(void))_asyncio_Task_all_tasks, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, _asyncio_Task_all_tasks__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400329
330static PyObject *
331_asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop);
332
333static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200334_asyncio_Task_all_tasks(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400335{
336 PyObject *return_value = NULL;
337 static const char * const _keywords[] = {"loop", NULL};
338 static _PyArg_Parser _parser = {"|O:all_tasks", _keywords, 0};
Yury Selivanov8d26aa92017-03-02 22:16:33 -0500339 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400340
Victor Stinner3e1fad62017-01-17 01:29:01 +0100341 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400342 &loop)) {
343 goto exit;
344 }
345 return_value = _asyncio_Task_all_tasks_impl(type, loop);
346
347exit:
348 return return_value;
349}
350
351PyDoc_STRVAR(_asyncio_Task__repr_info__doc__,
352"_repr_info($self, /)\n"
353"--\n"
354"\n");
355
356#define _ASYNCIO_TASK__REPR_INFO_METHODDEF \
357 {"_repr_info", (PyCFunction)_asyncio_Task__repr_info, METH_NOARGS, _asyncio_Task__repr_info__doc__},
358
359static PyObject *
360_asyncio_Task__repr_info_impl(TaskObj *self);
361
362static PyObject *
363_asyncio_Task__repr_info(TaskObj *self, PyObject *Py_UNUSED(ignored))
364{
365 return _asyncio_Task__repr_info_impl(self);
366}
367
368PyDoc_STRVAR(_asyncio_Task_cancel__doc__,
369"cancel($self, /)\n"
370"--\n"
371"\n"
372"Request that this task cancel itself.\n"
373"\n"
374"This arranges for a CancelledError to be thrown into the\n"
375"wrapped coroutine on the next cycle through the event loop.\n"
376"The coroutine then has a chance to clean up or even deny\n"
377"the request using try/except/finally.\n"
378"\n"
379"Unlike Future.cancel, this does not guarantee that the\n"
380"task will be cancelled: the exception might be caught and\n"
381"acted upon, delaying cancellation of the task or preventing\n"
382"cancellation completely. The task may also return a value or\n"
383"raise a different exception.\n"
384"\n"
385"Immediately after this method is called, Task.cancelled() will\n"
386"not return True (unless the task was already cancelled). A\n"
387"task will be marked as cancelled when the wrapped coroutine\n"
388"terminates with a CancelledError exception (even if cancel()\n"
389"was not called).");
390
391#define _ASYNCIO_TASK_CANCEL_METHODDEF \
392 {"cancel", (PyCFunction)_asyncio_Task_cancel, METH_NOARGS, _asyncio_Task_cancel__doc__},
393
394static PyObject *
395_asyncio_Task_cancel_impl(TaskObj *self);
396
397static PyObject *
398_asyncio_Task_cancel(TaskObj *self, PyObject *Py_UNUSED(ignored))
399{
400 return _asyncio_Task_cancel_impl(self);
401}
402
403PyDoc_STRVAR(_asyncio_Task_get_stack__doc__,
404"get_stack($self, /, *, limit=None)\n"
405"--\n"
406"\n"
407"Return the list of stack frames for this task\'s coroutine.\n"
408"\n"
409"If the coroutine is not done, this returns the stack where it is\n"
410"suspended. If the coroutine has completed successfully or was\n"
411"cancelled, this returns an empty list. If the coroutine was\n"
412"terminated by an exception, this returns the list of traceback\n"
413"frames.\n"
414"\n"
415"The frames are always ordered from oldest to newest.\n"
416"\n"
417"The optional limit gives the maximum number of frames to\n"
418"return; by default all available frames are returned. Its\n"
419"meaning differs depending on whether a stack or a traceback is\n"
420"returned: the newest frames of a stack are returned, but the\n"
421"oldest frames of a traceback are returned. (This matches the\n"
422"behavior of the traceback module.)\n"
423"\n"
424"For reasons beyond our control, only one stack frame is\n"
425"returned for a suspended coroutine.");
426
427#define _ASYNCIO_TASK_GET_STACK_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200428 {"get_stack", (PyCFunction)(void(*)(void))_asyncio_Task_get_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400429
430static PyObject *
431_asyncio_Task_get_stack_impl(TaskObj *self, PyObject *limit);
432
433static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200434_asyncio_Task_get_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400435{
436 PyObject *return_value = NULL;
437 static const char * const _keywords[] = {"limit", NULL};
438 static _PyArg_Parser _parser = {"|$O:get_stack", _keywords, 0};
439 PyObject *limit = Py_None;
440
Victor Stinner3e1fad62017-01-17 01:29:01 +0100441 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400442 &limit)) {
443 goto exit;
444 }
445 return_value = _asyncio_Task_get_stack_impl(self, limit);
446
447exit:
448 return return_value;
449}
450
451PyDoc_STRVAR(_asyncio_Task_print_stack__doc__,
452"print_stack($self, /, *, limit=None, file=None)\n"
453"--\n"
454"\n"
455"Print the stack or traceback for this task\'s coroutine.\n"
456"\n"
457"This produces output similar to that of the traceback module,\n"
458"for the frames retrieved by get_stack(). The limit argument\n"
459"is passed to get_stack(). The file argument is an I/O stream\n"
460"to which the output is written; by default output is written\n"
461"to sys.stderr.");
462
463#define _ASYNCIO_TASK_PRINT_STACK_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200464 {"print_stack", (PyCFunction)(void(*)(void))_asyncio_Task_print_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400465
466static PyObject *
467_asyncio_Task_print_stack_impl(TaskObj *self, PyObject *limit,
468 PyObject *file);
469
470static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200471_asyncio_Task_print_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400472{
473 PyObject *return_value = NULL;
474 static const char * const _keywords[] = {"limit", "file", NULL};
475 static _PyArg_Parser _parser = {"|$OO:print_stack", _keywords, 0};
476 PyObject *limit = Py_None;
477 PyObject *file = Py_None;
478
Victor Stinner3e1fad62017-01-17 01:29:01 +0100479 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400480 &limit, &file)) {
481 goto exit;
482 }
483 return_value = _asyncio_Task_print_stack_impl(self, limit, file);
484
485exit:
486 return return_value;
487}
488
Yury Selivanov0cf16f92017-12-25 10:48:15 -0500489PyDoc_STRVAR(_asyncio_Task_set_result__doc__,
490"set_result($self, result, /)\n"
491"--\n"
492"\n");
493
494#define _ASYNCIO_TASK_SET_RESULT_METHODDEF \
495 {"set_result", (PyCFunction)_asyncio_Task_set_result, METH_O, _asyncio_Task_set_result__doc__},
496
497PyDoc_STRVAR(_asyncio_Task_set_exception__doc__,
498"set_exception($self, exception, /)\n"
499"--\n"
500"\n");
501
502#define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \
503 {"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__},
504
Alex Grönholmcca4eec2018-08-09 00:06:47 +0300505PyDoc_STRVAR(_asyncio_Task_get_name__doc__,
506"get_name($self, /)\n"
507"--\n"
508"\n");
509
510#define _ASYNCIO_TASK_GET_NAME_METHODDEF \
511 {"get_name", (PyCFunction)_asyncio_Task_get_name, METH_NOARGS, _asyncio_Task_get_name__doc__},
512
513static PyObject *
514_asyncio_Task_get_name_impl(TaskObj *self);
515
516static PyObject *
517_asyncio_Task_get_name(TaskObj *self, PyObject *Py_UNUSED(ignored))
518{
519 return _asyncio_Task_get_name_impl(self);
520}
521
522PyDoc_STRVAR(_asyncio_Task_set_name__doc__,
523"set_name($self, value, /)\n"
524"--\n"
525"\n");
526
527#define _ASYNCIO_TASK_SET_NAME_METHODDEF \
528 {"set_name", (PyCFunction)_asyncio_Task_set_name, METH_O, _asyncio_Task_set_name__doc__},
529
Yury Selivanova70232f2017-12-13 14:49:42 -0500530PyDoc_STRVAR(_asyncio__get_running_loop__doc__,
531"_get_running_loop($module, /)\n"
532"--\n"
533"\n"
534"Return the running event loop or None.\n"
535"\n"
536"This is a low-level function intended to be used by event loops.\n"
537"This function is thread-specific.");
538
539#define _ASYNCIO__GET_RUNNING_LOOP_METHODDEF \
540 {"_get_running_loop", (PyCFunction)_asyncio__get_running_loop, METH_NOARGS, _asyncio__get_running_loop__doc__},
541
542static PyObject *
543_asyncio__get_running_loop_impl(PyObject *module);
544
545static PyObject *
546_asyncio__get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
547{
548 return _asyncio__get_running_loop_impl(module);
549}
550
551PyDoc_STRVAR(_asyncio__set_running_loop__doc__,
552"_set_running_loop($module, loop, /)\n"
553"--\n"
554"\n"
555"Set the running event loop.\n"
556"\n"
557"This is a low-level function intended to be used by event loops.\n"
558"This function is thread-specific.");
559
560#define _ASYNCIO__SET_RUNNING_LOOP_METHODDEF \
561 {"_set_running_loop", (PyCFunction)_asyncio__set_running_loop, METH_O, _asyncio__set_running_loop__doc__},
562
563PyDoc_STRVAR(_asyncio_get_event_loop__doc__,
564"get_event_loop($module, /)\n"
565"--\n"
566"\n"
567"Return an asyncio event loop.\n"
568"\n"
569"When called from a coroutine or a callback (e.g. scheduled with\n"
570"call_soon or similar API), this function will always return the\n"
571"running event loop.\n"
572"\n"
573"If there is no running event loop set, the function will return\n"
574"the result of `get_event_loop_policy().get_event_loop()` call.");
575
576#define _ASYNCIO_GET_EVENT_LOOP_METHODDEF \
577 {"get_event_loop", (PyCFunction)_asyncio_get_event_loop, METH_NOARGS, _asyncio_get_event_loop__doc__},
578
579static PyObject *
580_asyncio_get_event_loop_impl(PyObject *module);
581
582static PyObject *
583_asyncio_get_event_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
584{
585 return _asyncio_get_event_loop_impl(module);
586}
587
588PyDoc_STRVAR(_asyncio_get_running_loop__doc__,
589"get_running_loop($module, /)\n"
590"--\n"
591"\n"
592"Return the running event loop. Raise a RuntimeError if there is none.\n"
593"\n"
594"This function is thread-specific.");
595
596#define _ASYNCIO_GET_RUNNING_LOOP_METHODDEF \
597 {"get_running_loop", (PyCFunction)_asyncio_get_running_loop, METH_NOARGS, _asyncio_get_running_loop__doc__},
598
599static PyObject *
600_asyncio_get_running_loop_impl(PyObject *module);
601
602static PyObject *
603_asyncio_get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
604{
605 return _asyncio_get_running_loop_impl(module);
606}
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200607
608PyDoc_STRVAR(_asyncio__register_task__doc__,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500609"_register_task($module, /, task)\n"
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200610"--\n"
611"\n"
612"Register a new task in asyncio as executed by loop.\n"
613"\n"
614"Returns None.");
615
616#define _ASYNCIO__REGISTER_TASK_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200617 {"_register_task", (PyCFunction)(void(*)(void))_asyncio__register_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__},
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200618
619static PyObject *
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500620_asyncio__register_task_impl(PyObject *module, PyObject *task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200621
622static PyObject *
623_asyncio__register_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
624{
625 PyObject *return_value = NULL;
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500626 static const char * const _keywords[] = {"task", NULL};
627 static _PyArg_Parser _parser = {"O:_register_task", _keywords, 0};
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200628 PyObject *task;
629
630 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500631 &task)) {
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200632 goto exit;
633 }
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500634 return_value = _asyncio__register_task_impl(module, task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200635
636exit:
637 return return_value;
638}
639
640PyDoc_STRVAR(_asyncio__unregister_task__doc__,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500641"_unregister_task($module, /, task)\n"
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200642"--\n"
643"\n"
644"Unregister a task.\n"
645"\n"
646"Returns None.");
647
648#define _ASYNCIO__UNREGISTER_TASK_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200649 {"_unregister_task", (PyCFunction)(void(*)(void))_asyncio__unregister_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__},
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200650
651static PyObject *
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500652_asyncio__unregister_task_impl(PyObject *module, PyObject *task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200653
654static PyObject *
655_asyncio__unregister_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
656{
657 PyObject *return_value = NULL;
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500658 static const char * const _keywords[] = {"task", NULL};
659 static _PyArg_Parser _parser = {"O:_unregister_task", _keywords, 0};
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200660 PyObject *task;
661
662 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500663 &task)) {
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200664 goto exit;
665 }
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500666 return_value = _asyncio__unregister_task_impl(module, task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200667
668exit:
669 return return_value;
670}
671
672PyDoc_STRVAR(_asyncio__enter_task__doc__,
673"_enter_task($module, /, loop, task)\n"
674"--\n"
675"\n"
676"Enter into task execution or resume suspended task.\n"
677"\n"
678"Task belongs to loop.\n"
679"\n"
680"Returns None.");
681
682#define _ASYNCIO__ENTER_TASK_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200683 {"_enter_task", (PyCFunction)(void(*)(void))_asyncio__enter_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__},
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200684
685static PyObject *
686_asyncio__enter_task_impl(PyObject *module, PyObject *loop, PyObject *task);
687
688static PyObject *
689_asyncio__enter_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
690{
691 PyObject *return_value = NULL;
692 static const char * const _keywords[] = {"loop", "task", NULL};
693 static _PyArg_Parser _parser = {"OO:_enter_task", _keywords, 0};
694 PyObject *loop;
695 PyObject *task;
696
697 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
698 &loop, &task)) {
699 goto exit;
700 }
701 return_value = _asyncio__enter_task_impl(module, loop, task);
702
703exit:
704 return return_value;
705}
706
707PyDoc_STRVAR(_asyncio__leave_task__doc__,
708"_leave_task($module, /, loop, task)\n"
709"--\n"
710"\n"
711"Leave task execution or suspend a task.\n"
712"\n"
713"Task belongs to loop.\n"
714"\n"
715"Returns None.");
716
717#define _ASYNCIO__LEAVE_TASK_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200718 {"_leave_task", (PyCFunction)(void(*)(void))_asyncio__leave_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__},
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200719
720static PyObject *
721_asyncio__leave_task_impl(PyObject *module, PyObject *loop, PyObject *task);
722
723static PyObject *
724_asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
725{
726 PyObject *return_value = NULL;
727 static const char * const _keywords[] = {"loop", "task", NULL};
728 static _PyArg_Parser _parser = {"OO:_leave_task", _keywords, 0};
729 PyObject *loop;
730 PyObject *task;
731
732 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
733 &loop, &task)) {
734 goto exit;
735 }
736 return_value = _asyncio__leave_task_impl(module, loop, task);
737
738exit:
739 return return_value;
740}
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200741/*[clinic end generated code: output=fd474bdc8f03d5ae input=a9049054013a1b77]*/