blob: 9fc9d6b17c42644f490cfdd46aa3ac9086138d93 [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
255PyDoc_STRVAR(_asyncio_Future__schedule_callbacks__doc__,
256"_schedule_callbacks($self, /)\n"
257"--\n"
258"\n");
259
260#define _ASYNCIO_FUTURE__SCHEDULE_CALLBACKS_METHODDEF \
261 {"_schedule_callbacks", (PyCFunction)_asyncio_Future__schedule_callbacks, METH_NOARGS, _asyncio_Future__schedule_callbacks__doc__},
262
263static PyObject *
264_asyncio_Future__schedule_callbacks_impl(FutureObj *self);
265
266static PyObject *
267_asyncio_Future__schedule_callbacks(FutureObj *self, PyObject *Py_UNUSED(ignored))
268{
269 return _asyncio_Future__schedule_callbacks_impl(self);
270}
271
272PyDoc_STRVAR(_asyncio_Task___init____doc__,
273"Task(coro, *, loop=None)\n"
274"--\n"
275"\n"
276"A coroutine wrapped in a Future.");
277
278static int
279_asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop);
280
281static int
282_asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs)
283{
284 int return_value = -1;
285 static const char * const _keywords[] = {"coro", "loop", NULL};
286 static _PyArg_Parser _parser = {"O|$O:Task", _keywords, 0};
287 PyObject *coro;
Serhiy Storchakabca49392017-09-03 08:10:14 +0300288 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400289
290 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
291 &coro, &loop)) {
292 goto exit;
293 }
294 return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop);
295
296exit:
297 return return_value;
298}
299
300PyDoc_STRVAR(_asyncio_Task_current_task__doc__,
301"current_task($type, /, loop=None)\n"
302"--\n"
303"\n"
304"Return the currently running task in an event loop or None.\n"
305"\n"
306"By default the current task for the current event loop is returned.\n"
307"\n"
308"None is returned when called not in the context of a Task.");
309
310#define _ASYNCIO_TASK_CURRENT_TASK_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300311 {"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 -0400312
313static PyObject *
314_asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop);
315
316static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200317_asyncio_Task_current_task(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400318{
319 PyObject *return_value = NULL;
320 static const char * const _keywords[] = {"loop", NULL};
321 static _PyArg_Parser _parser = {"|O:current_task", _keywords, 0};
Yury Selivanov8d26aa92017-03-02 22:16:33 -0500322 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400323
Victor Stinner3e1fad62017-01-17 01:29:01 +0100324 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400325 &loop)) {
326 goto exit;
327 }
328 return_value = _asyncio_Task_current_task_impl(type, loop);
329
330exit:
331 return return_value;
332}
333
334PyDoc_STRVAR(_asyncio_Task_all_tasks__doc__,
335"all_tasks($type, /, loop=None)\n"
336"--\n"
337"\n"
338"Return a set of all tasks for an event loop.\n"
339"\n"
340"By default all tasks for the current event loop are returned.");
341
342#define _ASYNCIO_TASK_ALL_TASKS_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300343 {"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 -0400344
345static PyObject *
346_asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop);
347
348static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200349_asyncio_Task_all_tasks(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400350{
351 PyObject *return_value = NULL;
352 static const char * const _keywords[] = {"loop", NULL};
353 static _PyArg_Parser _parser = {"|O:all_tasks", _keywords, 0};
Yury Selivanov8d26aa92017-03-02 22:16:33 -0500354 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400355
Victor Stinner3e1fad62017-01-17 01:29:01 +0100356 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400357 &loop)) {
358 goto exit;
359 }
360 return_value = _asyncio_Task_all_tasks_impl(type, loop);
361
362exit:
363 return return_value;
364}
365
366PyDoc_STRVAR(_asyncio_Task__repr_info__doc__,
367"_repr_info($self, /)\n"
368"--\n"
369"\n");
370
371#define _ASYNCIO_TASK__REPR_INFO_METHODDEF \
372 {"_repr_info", (PyCFunction)_asyncio_Task__repr_info, METH_NOARGS, _asyncio_Task__repr_info__doc__},
373
374static PyObject *
375_asyncio_Task__repr_info_impl(TaskObj *self);
376
377static PyObject *
378_asyncio_Task__repr_info(TaskObj *self, PyObject *Py_UNUSED(ignored))
379{
380 return _asyncio_Task__repr_info_impl(self);
381}
382
383PyDoc_STRVAR(_asyncio_Task_cancel__doc__,
384"cancel($self, /)\n"
385"--\n"
386"\n"
387"Request that this task cancel itself.\n"
388"\n"
389"This arranges for a CancelledError to be thrown into the\n"
390"wrapped coroutine on the next cycle through the event loop.\n"
391"The coroutine then has a chance to clean up or even deny\n"
392"the request using try/except/finally.\n"
393"\n"
394"Unlike Future.cancel, this does not guarantee that the\n"
395"task will be cancelled: the exception might be caught and\n"
396"acted upon, delaying cancellation of the task or preventing\n"
397"cancellation completely. The task may also return a value or\n"
398"raise a different exception.\n"
399"\n"
400"Immediately after this method is called, Task.cancelled() will\n"
401"not return True (unless the task was already cancelled). A\n"
402"task will be marked as cancelled when the wrapped coroutine\n"
403"terminates with a CancelledError exception (even if cancel()\n"
404"was not called).");
405
406#define _ASYNCIO_TASK_CANCEL_METHODDEF \
407 {"cancel", (PyCFunction)_asyncio_Task_cancel, METH_NOARGS, _asyncio_Task_cancel__doc__},
408
409static PyObject *
410_asyncio_Task_cancel_impl(TaskObj *self);
411
412static PyObject *
413_asyncio_Task_cancel(TaskObj *self, PyObject *Py_UNUSED(ignored))
414{
415 return _asyncio_Task_cancel_impl(self);
416}
417
418PyDoc_STRVAR(_asyncio_Task_get_stack__doc__,
419"get_stack($self, /, *, limit=None)\n"
420"--\n"
421"\n"
422"Return the list of stack frames for this task\'s coroutine.\n"
423"\n"
424"If the coroutine is not done, this returns the stack where it is\n"
425"suspended. If the coroutine has completed successfully or was\n"
426"cancelled, this returns an empty list. If the coroutine was\n"
427"terminated by an exception, this returns the list of traceback\n"
428"frames.\n"
429"\n"
430"The frames are always ordered from oldest to newest.\n"
431"\n"
432"The optional limit gives the maximum number of frames to\n"
433"return; by default all available frames are returned. Its\n"
434"meaning differs depending on whether a stack or a traceback is\n"
435"returned: the newest frames of a stack are returned, but the\n"
436"oldest frames of a traceback are returned. (This matches the\n"
437"behavior of the traceback module.)\n"
438"\n"
439"For reasons beyond our control, only one stack frame is\n"
440"returned for a suspended coroutine.");
441
442#define _ASYNCIO_TASK_GET_STACK_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300443 {"get_stack", (PyCFunction)_asyncio_Task_get_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400444
445static PyObject *
446_asyncio_Task_get_stack_impl(TaskObj *self, PyObject *limit);
447
448static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200449_asyncio_Task_get_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400450{
451 PyObject *return_value = NULL;
452 static const char * const _keywords[] = {"limit", NULL};
453 static _PyArg_Parser _parser = {"|$O:get_stack", _keywords, 0};
454 PyObject *limit = Py_None;
455
Victor Stinner3e1fad62017-01-17 01:29:01 +0100456 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400457 &limit)) {
458 goto exit;
459 }
460 return_value = _asyncio_Task_get_stack_impl(self, limit);
461
462exit:
463 return return_value;
464}
465
466PyDoc_STRVAR(_asyncio_Task_print_stack__doc__,
467"print_stack($self, /, *, limit=None, file=None)\n"
468"--\n"
469"\n"
470"Print the stack or traceback for this task\'s coroutine.\n"
471"\n"
472"This produces output similar to that of the traceback module,\n"
473"for the frames retrieved by get_stack(). The limit argument\n"
474"is passed to get_stack(). The file argument is an I/O stream\n"
475"to which the output is written; by default output is written\n"
476"to sys.stderr.");
477
478#define _ASYNCIO_TASK_PRINT_STACK_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300479 {"print_stack", (PyCFunction)_asyncio_Task_print_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400480
481static PyObject *
482_asyncio_Task_print_stack_impl(TaskObj *self, PyObject *limit,
483 PyObject *file);
484
485static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200486_asyncio_Task_print_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400487{
488 PyObject *return_value = NULL;
489 static const char * const _keywords[] = {"limit", "file", NULL};
490 static _PyArg_Parser _parser = {"|$OO:print_stack", _keywords, 0};
491 PyObject *limit = Py_None;
492 PyObject *file = Py_None;
493
Victor Stinner3e1fad62017-01-17 01:29:01 +0100494 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400495 &limit, &file)) {
496 goto exit;
497 }
498 return_value = _asyncio_Task_print_stack_impl(self, limit, file);
499
500exit:
501 return return_value;
502}
503
504PyDoc_STRVAR(_asyncio_Task__step__doc__,
505"_step($self, /, exc=None)\n"
506"--\n"
507"\n");
508
509#define _ASYNCIO_TASK__STEP_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300510 {"_step", (PyCFunction)_asyncio_Task__step, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task__step__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400511
512static PyObject *
513_asyncio_Task__step_impl(TaskObj *self, PyObject *exc);
514
515static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200516_asyncio_Task__step(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400517{
518 PyObject *return_value = NULL;
519 static const char * const _keywords[] = {"exc", NULL};
520 static _PyArg_Parser _parser = {"|O:_step", _keywords, 0};
Serhiy Storchakabca49392017-09-03 08:10:14 +0300521 PyObject *exc = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400522
Victor Stinner3e1fad62017-01-17 01:29:01 +0100523 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400524 &exc)) {
525 goto exit;
526 }
527 return_value = _asyncio_Task__step_impl(self, exc);
528
529exit:
530 return return_value;
531}
532
533PyDoc_STRVAR(_asyncio_Task__wakeup__doc__,
534"_wakeup($self, /, fut)\n"
535"--\n"
536"\n");
537
538#define _ASYNCIO_TASK__WAKEUP_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300539 {"_wakeup", (PyCFunction)_asyncio_Task__wakeup, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task__wakeup__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400540
541static PyObject *
542_asyncio_Task__wakeup_impl(TaskObj *self, PyObject *fut);
543
544static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200545_asyncio_Task__wakeup(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400546{
547 PyObject *return_value = NULL;
548 static const char * const _keywords[] = {"fut", NULL};
549 static _PyArg_Parser _parser = {"O:_wakeup", _keywords, 0};
550 PyObject *fut;
551
Victor Stinner3e1fad62017-01-17 01:29:01 +0100552 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400553 &fut)) {
554 goto exit;
555 }
556 return_value = _asyncio_Task__wakeup_impl(self, fut);
557
558exit:
559 return return_value;
560}
Yury Selivanova70232f2017-12-13 14:49:42 -0500561
Yury Selivanov0cf16f92017-12-25 10:48:15 -0500562PyDoc_STRVAR(_asyncio_Task_set_result__doc__,
563"set_result($self, result, /)\n"
564"--\n"
565"\n");
566
567#define _ASYNCIO_TASK_SET_RESULT_METHODDEF \
568 {"set_result", (PyCFunction)_asyncio_Task_set_result, METH_O, _asyncio_Task_set_result__doc__},
569
570PyDoc_STRVAR(_asyncio_Task_set_exception__doc__,
571"set_exception($self, exception, /)\n"
572"--\n"
573"\n");
574
575#define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \
576 {"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__},
577
Yury Selivanova70232f2017-12-13 14:49:42 -0500578PyDoc_STRVAR(_asyncio__get_running_loop__doc__,
579"_get_running_loop($module, /)\n"
580"--\n"
581"\n"
582"Return the running event loop or None.\n"
583"\n"
584"This is a low-level function intended to be used by event loops.\n"
585"This function is thread-specific.");
586
587#define _ASYNCIO__GET_RUNNING_LOOP_METHODDEF \
588 {"_get_running_loop", (PyCFunction)_asyncio__get_running_loop, METH_NOARGS, _asyncio__get_running_loop__doc__},
589
590static PyObject *
591_asyncio__get_running_loop_impl(PyObject *module);
592
593static PyObject *
594_asyncio__get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
595{
596 return _asyncio__get_running_loop_impl(module);
597}
598
599PyDoc_STRVAR(_asyncio__set_running_loop__doc__,
600"_set_running_loop($module, loop, /)\n"
601"--\n"
602"\n"
603"Set the running event loop.\n"
604"\n"
605"This is a low-level function intended to be used by event loops.\n"
606"This function is thread-specific.");
607
608#define _ASYNCIO__SET_RUNNING_LOOP_METHODDEF \
609 {"_set_running_loop", (PyCFunction)_asyncio__set_running_loop, METH_O, _asyncio__set_running_loop__doc__},
610
611PyDoc_STRVAR(_asyncio_get_event_loop__doc__,
612"get_event_loop($module, /)\n"
613"--\n"
614"\n"
615"Return an asyncio event loop.\n"
616"\n"
617"When called from a coroutine or a callback (e.g. scheduled with\n"
618"call_soon or similar API), this function will always return the\n"
619"running event loop.\n"
620"\n"
621"If there is no running event loop set, the function will return\n"
622"the result of `get_event_loop_policy().get_event_loop()` call.");
623
624#define _ASYNCIO_GET_EVENT_LOOP_METHODDEF \
625 {"get_event_loop", (PyCFunction)_asyncio_get_event_loop, METH_NOARGS, _asyncio_get_event_loop__doc__},
626
627static PyObject *
628_asyncio_get_event_loop_impl(PyObject *module);
629
630static PyObject *
631_asyncio_get_event_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
632{
633 return _asyncio_get_event_loop_impl(module);
634}
635
636PyDoc_STRVAR(_asyncio_get_running_loop__doc__,
637"get_running_loop($module, /)\n"
638"--\n"
639"\n"
640"Return the running event loop. Raise a RuntimeError if there is none.\n"
641"\n"
642"This function is thread-specific.");
643
644#define _ASYNCIO_GET_RUNNING_LOOP_METHODDEF \
645 {"get_running_loop", (PyCFunction)_asyncio_get_running_loop, METH_NOARGS, _asyncio_get_running_loop__doc__},
646
647static PyObject *
648_asyncio_get_running_loop_impl(PyObject *module);
649
650static PyObject *
651_asyncio_get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
652{
653 return _asyncio_get_running_loop_impl(module);
654}
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200655
656PyDoc_STRVAR(_asyncio__register_task__doc__,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500657"_register_task($module, /, task)\n"
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200658"--\n"
659"\n"
660"Register a new task in asyncio as executed by loop.\n"
661"\n"
662"Returns None.");
663
664#define _ASYNCIO__REGISTER_TASK_METHODDEF \
665 {"_register_task", (PyCFunction)_asyncio__register_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__},
666
667static PyObject *
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500668_asyncio__register_task_impl(PyObject *module, PyObject *task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200669
670static PyObject *
671_asyncio__register_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
672{
673 PyObject *return_value = NULL;
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500674 static const char * const _keywords[] = {"task", NULL};
675 static _PyArg_Parser _parser = {"O:_register_task", _keywords, 0};
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200676 PyObject *task;
677
678 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500679 &task)) {
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200680 goto exit;
681 }
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500682 return_value = _asyncio__register_task_impl(module, task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200683
684exit:
685 return return_value;
686}
687
688PyDoc_STRVAR(_asyncio__unregister_task__doc__,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500689"_unregister_task($module, /, task)\n"
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200690"--\n"
691"\n"
692"Unregister a task.\n"
693"\n"
694"Returns None.");
695
696#define _ASYNCIO__UNREGISTER_TASK_METHODDEF \
697 {"_unregister_task", (PyCFunction)_asyncio__unregister_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__},
698
699static PyObject *
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500700_asyncio__unregister_task_impl(PyObject *module, PyObject *task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200701
702static PyObject *
703_asyncio__unregister_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
704{
705 PyObject *return_value = NULL;
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500706 static const char * const _keywords[] = {"task", NULL};
707 static _PyArg_Parser _parser = {"O:_unregister_task", _keywords, 0};
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200708 PyObject *task;
709
710 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500711 &task)) {
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200712 goto exit;
713 }
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500714 return_value = _asyncio__unregister_task_impl(module, task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200715
716exit:
717 return return_value;
718}
719
720PyDoc_STRVAR(_asyncio__enter_task__doc__,
721"_enter_task($module, /, loop, task)\n"
722"--\n"
723"\n"
724"Enter into task execution or resume suspended task.\n"
725"\n"
726"Task belongs to loop.\n"
727"\n"
728"Returns None.");
729
730#define _ASYNCIO__ENTER_TASK_METHODDEF \
731 {"_enter_task", (PyCFunction)_asyncio__enter_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__},
732
733static PyObject *
734_asyncio__enter_task_impl(PyObject *module, PyObject *loop, PyObject *task);
735
736static PyObject *
737_asyncio__enter_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
738{
739 PyObject *return_value = NULL;
740 static const char * const _keywords[] = {"loop", "task", NULL};
741 static _PyArg_Parser _parser = {"OO:_enter_task", _keywords, 0};
742 PyObject *loop;
743 PyObject *task;
744
745 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
746 &loop, &task)) {
747 goto exit;
748 }
749 return_value = _asyncio__enter_task_impl(module, loop, task);
750
751exit:
752 return return_value;
753}
754
755PyDoc_STRVAR(_asyncio__leave_task__doc__,
756"_leave_task($module, /, loop, task)\n"
757"--\n"
758"\n"
759"Leave task execution or suspend a task.\n"
760"\n"
761"Task belongs to loop.\n"
762"\n"
763"Returns None.");
764
765#define _ASYNCIO__LEAVE_TASK_METHODDEF \
766 {"_leave_task", (PyCFunction)_asyncio__leave_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__},
767
768static PyObject *
769_asyncio__leave_task_impl(PyObject *module, PyObject *loop, PyObject *task);
770
771static PyObject *
772_asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
773{
774 PyObject *return_value = NULL;
775 static const char * const _keywords[] = {"loop", "task", NULL};
776 static _PyArg_Parser _parser = {"OO:_leave_task", _keywords, 0};
777 PyObject *loop;
778 PyObject *task;
779
780 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
781 &loop, &task)) {
782 goto exit;
783 }
784 return_value = _asyncio__leave_task_impl(module, loop, task);
785
786exit:
787 return return_value;
788}
Yury Selivanovf23746a2018-01-22 19:11:18 -0500789/*[clinic end generated code: output=bcbaf1b2480f4aa9 input=a9049054013a1b77]*/