blob: d8e1b6a7987956bca43a8c06e5991467746643fa [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 \
Yury Selivanovf23746a2018-01-22 19:11:18 -0500123 {"add_done_callback", (PyCFunction)_asyncio_Future_add_done_callback, METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_add_done_callback__doc__},
124
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__,
256"Task(coro, *, loop=None)\n"
257"--\n"
258"\n"
259"A coroutine wrapped in a Future.");
260
261static int
262_asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop);
263
264static int
265_asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs)
266{
267 int return_value = -1;
268 static const char * const _keywords[] = {"coro", "loop", NULL};
269 static _PyArg_Parser _parser = {"O|$O:Task", _keywords, 0};
270 PyObject *coro;
Serhiy Storchakabca49392017-09-03 08:10:14 +0300271 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400272
273 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
274 &coro, &loop)) {
275 goto exit;
276 }
277 return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop);
278
279exit:
280 return return_value;
281}
282
283PyDoc_STRVAR(_asyncio_Task_current_task__doc__,
284"current_task($type, /, loop=None)\n"
285"--\n"
286"\n"
287"Return the currently running task in an event loop or None.\n"
288"\n"
289"By default the current task for the current event loop is returned.\n"
290"\n"
291"None is returned when called not in the context of a Task.");
292
293#define _ASYNCIO_TASK_CURRENT_TASK_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300294 {"current_task", (PyCFunction)_asyncio_Task_current_task, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, _asyncio_Task_current_task__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400295
296static PyObject *
297_asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop);
298
299static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200300_asyncio_Task_current_task(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400301{
302 PyObject *return_value = NULL;
303 static const char * const _keywords[] = {"loop", NULL};
304 static _PyArg_Parser _parser = {"|O:current_task", _keywords, 0};
Yury Selivanov8d26aa92017-03-02 22:16:33 -0500305 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400306
Victor Stinner3e1fad62017-01-17 01:29:01 +0100307 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400308 &loop)) {
309 goto exit;
310 }
311 return_value = _asyncio_Task_current_task_impl(type, loop);
312
313exit:
314 return return_value;
315}
316
317PyDoc_STRVAR(_asyncio_Task_all_tasks__doc__,
318"all_tasks($type, /, loop=None)\n"
319"--\n"
320"\n"
321"Return a set of all tasks for an event loop.\n"
322"\n"
323"By default all tasks for the current event loop are returned.");
324
325#define _ASYNCIO_TASK_ALL_TASKS_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300326 {"all_tasks", (PyCFunction)_asyncio_Task_all_tasks, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, _asyncio_Task_all_tasks__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400327
328static PyObject *
329_asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop);
330
331static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200332_asyncio_Task_all_tasks(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400333{
334 PyObject *return_value = NULL;
335 static const char * const _keywords[] = {"loop", NULL};
336 static _PyArg_Parser _parser = {"|O:all_tasks", _keywords, 0};
Yury Selivanov8d26aa92017-03-02 22:16:33 -0500337 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400338
Victor Stinner3e1fad62017-01-17 01:29:01 +0100339 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400340 &loop)) {
341 goto exit;
342 }
343 return_value = _asyncio_Task_all_tasks_impl(type, loop);
344
345exit:
346 return return_value;
347}
348
349PyDoc_STRVAR(_asyncio_Task__repr_info__doc__,
350"_repr_info($self, /)\n"
351"--\n"
352"\n");
353
354#define _ASYNCIO_TASK__REPR_INFO_METHODDEF \
355 {"_repr_info", (PyCFunction)_asyncio_Task__repr_info, METH_NOARGS, _asyncio_Task__repr_info__doc__},
356
357static PyObject *
358_asyncio_Task__repr_info_impl(TaskObj *self);
359
360static PyObject *
361_asyncio_Task__repr_info(TaskObj *self, PyObject *Py_UNUSED(ignored))
362{
363 return _asyncio_Task__repr_info_impl(self);
364}
365
366PyDoc_STRVAR(_asyncio_Task_cancel__doc__,
367"cancel($self, /)\n"
368"--\n"
369"\n"
370"Request that this task cancel itself.\n"
371"\n"
372"This arranges for a CancelledError to be thrown into the\n"
373"wrapped coroutine on the next cycle through the event loop.\n"
374"The coroutine then has a chance to clean up or even deny\n"
375"the request using try/except/finally.\n"
376"\n"
377"Unlike Future.cancel, this does not guarantee that the\n"
378"task will be cancelled: the exception might be caught and\n"
379"acted upon, delaying cancellation of the task or preventing\n"
380"cancellation completely. The task may also return a value or\n"
381"raise a different exception.\n"
382"\n"
383"Immediately after this method is called, Task.cancelled() will\n"
384"not return True (unless the task was already cancelled). A\n"
385"task will be marked as cancelled when the wrapped coroutine\n"
386"terminates with a CancelledError exception (even if cancel()\n"
387"was not called).");
388
389#define _ASYNCIO_TASK_CANCEL_METHODDEF \
390 {"cancel", (PyCFunction)_asyncio_Task_cancel, METH_NOARGS, _asyncio_Task_cancel__doc__},
391
392static PyObject *
393_asyncio_Task_cancel_impl(TaskObj *self);
394
395static PyObject *
396_asyncio_Task_cancel(TaskObj *self, PyObject *Py_UNUSED(ignored))
397{
398 return _asyncio_Task_cancel_impl(self);
399}
400
401PyDoc_STRVAR(_asyncio_Task_get_stack__doc__,
402"get_stack($self, /, *, limit=None)\n"
403"--\n"
404"\n"
405"Return the list of stack frames for this task\'s coroutine.\n"
406"\n"
407"If the coroutine is not done, this returns the stack where it is\n"
408"suspended. If the coroutine has completed successfully or was\n"
409"cancelled, this returns an empty list. If the coroutine was\n"
410"terminated by an exception, this returns the list of traceback\n"
411"frames.\n"
412"\n"
413"The frames are always ordered from oldest to newest.\n"
414"\n"
415"The optional limit gives the maximum number of frames to\n"
416"return; by default all available frames are returned. Its\n"
417"meaning differs depending on whether a stack or a traceback is\n"
418"returned: the newest frames of a stack are returned, but the\n"
419"oldest frames of a traceback are returned. (This matches the\n"
420"behavior of the traceback module.)\n"
421"\n"
422"For reasons beyond our control, only one stack frame is\n"
423"returned for a suspended coroutine.");
424
425#define _ASYNCIO_TASK_GET_STACK_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300426 {"get_stack", (PyCFunction)_asyncio_Task_get_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400427
428static PyObject *
429_asyncio_Task_get_stack_impl(TaskObj *self, PyObject *limit);
430
431static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200432_asyncio_Task_get_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400433{
434 PyObject *return_value = NULL;
435 static const char * const _keywords[] = {"limit", NULL};
436 static _PyArg_Parser _parser = {"|$O:get_stack", _keywords, 0};
437 PyObject *limit = Py_None;
438
Victor Stinner3e1fad62017-01-17 01:29:01 +0100439 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400440 &limit)) {
441 goto exit;
442 }
443 return_value = _asyncio_Task_get_stack_impl(self, limit);
444
445exit:
446 return return_value;
447}
448
449PyDoc_STRVAR(_asyncio_Task_print_stack__doc__,
450"print_stack($self, /, *, limit=None, file=None)\n"
451"--\n"
452"\n"
453"Print the stack or traceback for this task\'s coroutine.\n"
454"\n"
455"This produces output similar to that of the traceback module,\n"
456"for the frames retrieved by get_stack(). The limit argument\n"
457"is passed to get_stack(). The file argument is an I/O stream\n"
458"to which the output is written; by default output is written\n"
459"to sys.stderr.");
460
461#define _ASYNCIO_TASK_PRINT_STACK_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300462 {"print_stack", (PyCFunction)_asyncio_Task_print_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400463
464static PyObject *
465_asyncio_Task_print_stack_impl(TaskObj *self, PyObject *limit,
466 PyObject *file);
467
468static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200469_asyncio_Task_print_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400470{
471 PyObject *return_value = NULL;
472 static const char * const _keywords[] = {"limit", "file", NULL};
473 static _PyArg_Parser _parser = {"|$OO:print_stack", _keywords, 0};
474 PyObject *limit = Py_None;
475 PyObject *file = Py_None;
476
Victor Stinner3e1fad62017-01-17 01:29:01 +0100477 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400478 &limit, &file)) {
479 goto exit;
480 }
481 return_value = _asyncio_Task_print_stack_impl(self, limit, file);
482
483exit:
484 return return_value;
485}
486
Yury Selivanov0cf16f92017-12-25 10:48:15 -0500487PyDoc_STRVAR(_asyncio_Task_set_result__doc__,
488"set_result($self, result, /)\n"
489"--\n"
490"\n");
491
492#define _ASYNCIO_TASK_SET_RESULT_METHODDEF \
493 {"set_result", (PyCFunction)_asyncio_Task_set_result, METH_O, _asyncio_Task_set_result__doc__},
494
495PyDoc_STRVAR(_asyncio_Task_set_exception__doc__,
496"set_exception($self, exception, /)\n"
497"--\n"
498"\n");
499
500#define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \
501 {"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__},
502
Yury Selivanova70232f2017-12-13 14:49:42 -0500503PyDoc_STRVAR(_asyncio__get_running_loop__doc__,
504"_get_running_loop($module, /)\n"
505"--\n"
506"\n"
507"Return the running event loop or None.\n"
508"\n"
509"This is a low-level function intended to be used by event loops.\n"
510"This function is thread-specific.");
511
512#define _ASYNCIO__GET_RUNNING_LOOP_METHODDEF \
513 {"_get_running_loop", (PyCFunction)_asyncio__get_running_loop, METH_NOARGS, _asyncio__get_running_loop__doc__},
514
515static PyObject *
516_asyncio__get_running_loop_impl(PyObject *module);
517
518static PyObject *
519_asyncio__get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
520{
521 return _asyncio__get_running_loop_impl(module);
522}
523
524PyDoc_STRVAR(_asyncio__set_running_loop__doc__,
525"_set_running_loop($module, loop, /)\n"
526"--\n"
527"\n"
528"Set the running event loop.\n"
529"\n"
530"This is a low-level function intended to be used by event loops.\n"
531"This function is thread-specific.");
532
533#define _ASYNCIO__SET_RUNNING_LOOP_METHODDEF \
534 {"_set_running_loop", (PyCFunction)_asyncio__set_running_loop, METH_O, _asyncio__set_running_loop__doc__},
535
536PyDoc_STRVAR(_asyncio_get_event_loop__doc__,
537"get_event_loop($module, /)\n"
538"--\n"
539"\n"
540"Return an asyncio event loop.\n"
541"\n"
542"When called from a coroutine or a callback (e.g. scheduled with\n"
543"call_soon or similar API), this function will always return the\n"
544"running event loop.\n"
545"\n"
546"If there is no running event loop set, the function will return\n"
547"the result of `get_event_loop_policy().get_event_loop()` call.");
548
549#define _ASYNCIO_GET_EVENT_LOOP_METHODDEF \
550 {"get_event_loop", (PyCFunction)_asyncio_get_event_loop, METH_NOARGS, _asyncio_get_event_loop__doc__},
551
552static PyObject *
553_asyncio_get_event_loop_impl(PyObject *module);
554
555static PyObject *
556_asyncio_get_event_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
557{
558 return _asyncio_get_event_loop_impl(module);
559}
560
561PyDoc_STRVAR(_asyncio_get_running_loop__doc__,
562"get_running_loop($module, /)\n"
563"--\n"
564"\n"
565"Return the running event loop. Raise a RuntimeError if there is none.\n"
566"\n"
567"This function is thread-specific.");
568
569#define _ASYNCIO_GET_RUNNING_LOOP_METHODDEF \
570 {"get_running_loop", (PyCFunction)_asyncio_get_running_loop, METH_NOARGS, _asyncio_get_running_loop__doc__},
571
572static PyObject *
573_asyncio_get_running_loop_impl(PyObject *module);
574
575static PyObject *
576_asyncio_get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
577{
578 return _asyncio_get_running_loop_impl(module);
579}
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200580
581PyDoc_STRVAR(_asyncio__register_task__doc__,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500582"_register_task($module, /, task)\n"
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200583"--\n"
584"\n"
585"Register a new task in asyncio as executed by loop.\n"
586"\n"
587"Returns None.");
588
589#define _ASYNCIO__REGISTER_TASK_METHODDEF \
590 {"_register_task", (PyCFunction)_asyncio__register_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__},
591
592static PyObject *
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500593_asyncio__register_task_impl(PyObject *module, PyObject *task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200594
595static PyObject *
596_asyncio__register_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
597{
598 PyObject *return_value = NULL;
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500599 static const char * const _keywords[] = {"task", NULL};
600 static _PyArg_Parser _parser = {"O:_register_task", _keywords, 0};
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200601 PyObject *task;
602
603 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500604 &task)) {
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200605 goto exit;
606 }
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500607 return_value = _asyncio__register_task_impl(module, task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200608
609exit:
610 return return_value;
611}
612
613PyDoc_STRVAR(_asyncio__unregister_task__doc__,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500614"_unregister_task($module, /, task)\n"
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200615"--\n"
616"\n"
617"Unregister a task.\n"
618"\n"
619"Returns None.");
620
621#define _ASYNCIO__UNREGISTER_TASK_METHODDEF \
622 {"_unregister_task", (PyCFunction)_asyncio__unregister_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__},
623
624static PyObject *
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500625_asyncio__unregister_task_impl(PyObject *module, PyObject *task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200626
627static PyObject *
628_asyncio__unregister_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
629{
630 PyObject *return_value = NULL;
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500631 static const char * const _keywords[] = {"task", NULL};
632 static _PyArg_Parser _parser = {"O:_unregister_task", _keywords, 0};
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200633 PyObject *task;
634
635 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500636 &task)) {
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200637 goto exit;
638 }
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500639 return_value = _asyncio__unregister_task_impl(module, task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200640
641exit:
642 return return_value;
643}
644
645PyDoc_STRVAR(_asyncio__enter_task__doc__,
646"_enter_task($module, /, loop, task)\n"
647"--\n"
648"\n"
649"Enter into task execution or resume suspended task.\n"
650"\n"
651"Task belongs to loop.\n"
652"\n"
653"Returns None.");
654
655#define _ASYNCIO__ENTER_TASK_METHODDEF \
656 {"_enter_task", (PyCFunction)_asyncio__enter_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__},
657
658static PyObject *
659_asyncio__enter_task_impl(PyObject *module, PyObject *loop, PyObject *task);
660
661static PyObject *
662_asyncio__enter_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
663{
664 PyObject *return_value = NULL;
665 static const char * const _keywords[] = {"loop", "task", NULL};
666 static _PyArg_Parser _parser = {"OO:_enter_task", _keywords, 0};
667 PyObject *loop;
668 PyObject *task;
669
670 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
671 &loop, &task)) {
672 goto exit;
673 }
674 return_value = _asyncio__enter_task_impl(module, loop, task);
675
676exit:
677 return return_value;
678}
679
680PyDoc_STRVAR(_asyncio__leave_task__doc__,
681"_leave_task($module, /, loop, task)\n"
682"--\n"
683"\n"
684"Leave task execution or suspend a task.\n"
685"\n"
686"Task belongs to loop.\n"
687"\n"
688"Returns None.");
689
690#define _ASYNCIO__LEAVE_TASK_METHODDEF \
691 {"_leave_task", (PyCFunction)_asyncio__leave_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__},
692
693static PyObject *
694_asyncio__leave_task_impl(PyObject *module, PyObject *loop, PyObject *task);
695
696static PyObject *
697_asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
698{
699 PyObject *return_value = NULL;
700 static const char * const _keywords[] = {"loop", "task", NULL};
701 static _PyArg_Parser _parser = {"OO:_leave_task", _keywords, 0};
702 PyObject *loop;
703 PyObject *task;
704
705 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
706 &loop, &task)) {
707 goto exit;
708 }
709 return_value = _asyncio__leave_task_impl(module, loop, task);
710
711exit:
712 return return_value;
713}
Yury Selivanov22feeb82018-01-24 11:31:01 -0500714/*[clinic end generated code: output=b6148b0134e7a819 input=a9049054013a1b77]*/