blob: f2e0f405ada5d0bccc04e50629e1fa8cb2272d6c [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__,
113"add_done_callback($self, fn, /)\n"
114"--\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 \
123 {"add_done_callback", (PyCFunction)_asyncio_Future_add_done_callback, METH_O, _asyncio_Future_add_done_callback__doc__},
124
125PyDoc_STRVAR(_asyncio_Future_remove_done_callback__doc__,
126"remove_done_callback($self, fn, /)\n"
127"--\n"
128"\n"
129"Remove all instances of a callback from the \"call when done\" list.\n"
130"\n"
131"Returns the number of callbacks removed.");
132
133#define _ASYNCIO_FUTURE_REMOVE_DONE_CALLBACK_METHODDEF \
134 {"remove_done_callback", (PyCFunction)_asyncio_Future_remove_done_callback, METH_O, _asyncio_Future_remove_done_callback__doc__},
135
136PyDoc_STRVAR(_asyncio_Future_cancel__doc__,
137"cancel($self, /)\n"
138"--\n"
139"\n"
140"Cancel the future and schedule callbacks.\n"
141"\n"
142"If the future is already done or cancelled, return False. Otherwise,\n"
143"change the future\'s state to cancelled, schedule the callbacks and\n"
144"return True.");
145
146#define _ASYNCIO_FUTURE_CANCEL_METHODDEF \
147 {"cancel", (PyCFunction)_asyncio_Future_cancel, METH_NOARGS, _asyncio_Future_cancel__doc__},
148
149static PyObject *
150_asyncio_Future_cancel_impl(FutureObj *self);
151
152static PyObject *
153_asyncio_Future_cancel(FutureObj *self, PyObject *Py_UNUSED(ignored))
154{
155 return _asyncio_Future_cancel_impl(self);
156}
157
158PyDoc_STRVAR(_asyncio_Future_cancelled__doc__,
159"cancelled($self, /)\n"
160"--\n"
161"\n"
162"Return True if the future was cancelled.");
163
164#define _ASYNCIO_FUTURE_CANCELLED_METHODDEF \
165 {"cancelled", (PyCFunction)_asyncio_Future_cancelled, METH_NOARGS, _asyncio_Future_cancelled__doc__},
166
167static PyObject *
168_asyncio_Future_cancelled_impl(FutureObj *self);
169
170static PyObject *
171_asyncio_Future_cancelled(FutureObj *self, PyObject *Py_UNUSED(ignored))
172{
173 return _asyncio_Future_cancelled_impl(self);
174}
175
176PyDoc_STRVAR(_asyncio_Future_done__doc__,
177"done($self, /)\n"
178"--\n"
179"\n"
180"Return True if the future is done.\n"
181"\n"
182"Done means either that a result / exception are available, or that the\n"
183"future was cancelled.");
184
185#define _ASYNCIO_FUTURE_DONE_METHODDEF \
186 {"done", (PyCFunction)_asyncio_Future_done, METH_NOARGS, _asyncio_Future_done__doc__},
187
188static PyObject *
189_asyncio_Future_done_impl(FutureObj *self);
190
191static PyObject *
192_asyncio_Future_done(FutureObj *self, PyObject *Py_UNUSED(ignored))
193{
194 return _asyncio_Future_done_impl(self);
195}
196
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500197PyDoc_STRVAR(_asyncio_Future_get_loop__doc__,
198"get_loop($self, /)\n"
199"--\n"
200"\n"
201"Return the event loop the Future is bound to.");
202
203#define _ASYNCIO_FUTURE_GET_LOOP_METHODDEF \
204 {"get_loop", (PyCFunction)_asyncio_Future_get_loop, METH_NOARGS, _asyncio_Future_get_loop__doc__},
205
206static PyObject *
207_asyncio_Future_get_loop_impl(FutureObj *self);
208
209static PyObject *
210_asyncio_Future_get_loop(FutureObj *self, PyObject *Py_UNUSED(ignored))
211{
212 return _asyncio_Future_get_loop_impl(self);
213}
214
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400215PyDoc_STRVAR(_asyncio_Future__repr_info__doc__,
216"_repr_info($self, /)\n"
217"--\n"
218"\n");
219
220#define _ASYNCIO_FUTURE__REPR_INFO_METHODDEF \
221 {"_repr_info", (PyCFunction)_asyncio_Future__repr_info, METH_NOARGS, _asyncio_Future__repr_info__doc__},
222
223static PyObject *
224_asyncio_Future__repr_info_impl(FutureObj *self);
225
226static PyObject *
227_asyncio_Future__repr_info(FutureObj *self, PyObject *Py_UNUSED(ignored))
228{
229 return _asyncio_Future__repr_info_impl(self);
230}
231
232PyDoc_STRVAR(_asyncio_Future__schedule_callbacks__doc__,
233"_schedule_callbacks($self, /)\n"
234"--\n"
235"\n");
236
237#define _ASYNCIO_FUTURE__SCHEDULE_CALLBACKS_METHODDEF \
238 {"_schedule_callbacks", (PyCFunction)_asyncio_Future__schedule_callbacks, METH_NOARGS, _asyncio_Future__schedule_callbacks__doc__},
239
240static PyObject *
241_asyncio_Future__schedule_callbacks_impl(FutureObj *self);
242
243static PyObject *
244_asyncio_Future__schedule_callbacks(FutureObj *self, PyObject *Py_UNUSED(ignored))
245{
246 return _asyncio_Future__schedule_callbacks_impl(self);
247}
248
249PyDoc_STRVAR(_asyncio_Task___init____doc__,
250"Task(coro, *, loop=None)\n"
251"--\n"
252"\n"
253"A coroutine wrapped in a Future.");
254
255static int
256_asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop);
257
258static int
259_asyncio_Task___init__(PyObject *self, PyObject *args, PyObject *kwargs)
260{
261 int return_value = -1;
262 static const char * const _keywords[] = {"coro", "loop", NULL};
263 static _PyArg_Parser _parser = {"O|$O:Task", _keywords, 0};
264 PyObject *coro;
Serhiy Storchakabca49392017-09-03 08:10:14 +0300265 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400266
267 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
268 &coro, &loop)) {
269 goto exit;
270 }
271 return_value = _asyncio_Task___init___impl((TaskObj *)self, coro, loop);
272
273exit:
274 return return_value;
275}
276
277PyDoc_STRVAR(_asyncio_Task_current_task__doc__,
278"current_task($type, /, loop=None)\n"
279"--\n"
280"\n"
281"Return the currently running task in an event loop or None.\n"
282"\n"
283"By default the current task for the current event loop is returned.\n"
284"\n"
285"None is returned when called not in the context of a Task.");
286
287#define _ASYNCIO_TASK_CURRENT_TASK_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300288 {"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 -0400289
290static PyObject *
291_asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop);
292
293static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200294_asyncio_Task_current_task(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400295{
296 PyObject *return_value = NULL;
297 static const char * const _keywords[] = {"loop", NULL};
298 static _PyArg_Parser _parser = {"|O:current_task", _keywords, 0};
Yury Selivanov8d26aa92017-03-02 22:16:33 -0500299 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400300
Victor Stinner3e1fad62017-01-17 01:29:01 +0100301 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400302 &loop)) {
303 goto exit;
304 }
305 return_value = _asyncio_Task_current_task_impl(type, loop);
306
307exit:
308 return return_value;
309}
310
311PyDoc_STRVAR(_asyncio_Task_all_tasks__doc__,
312"all_tasks($type, /, loop=None)\n"
313"--\n"
314"\n"
315"Return a set of all tasks for an event loop.\n"
316"\n"
317"By default all tasks for the current event loop are returned.");
318
319#define _ASYNCIO_TASK_ALL_TASKS_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300320 {"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 -0400321
322static PyObject *
323_asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop);
324
325static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200326_asyncio_Task_all_tasks(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400327{
328 PyObject *return_value = NULL;
329 static const char * const _keywords[] = {"loop", NULL};
330 static _PyArg_Parser _parser = {"|O:all_tasks", _keywords, 0};
Yury Selivanov8d26aa92017-03-02 22:16:33 -0500331 PyObject *loop = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400332
Victor Stinner3e1fad62017-01-17 01:29:01 +0100333 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400334 &loop)) {
335 goto exit;
336 }
337 return_value = _asyncio_Task_all_tasks_impl(type, loop);
338
339exit:
340 return return_value;
341}
342
343PyDoc_STRVAR(_asyncio_Task__repr_info__doc__,
344"_repr_info($self, /)\n"
345"--\n"
346"\n");
347
348#define _ASYNCIO_TASK__REPR_INFO_METHODDEF \
349 {"_repr_info", (PyCFunction)_asyncio_Task__repr_info, METH_NOARGS, _asyncio_Task__repr_info__doc__},
350
351static PyObject *
352_asyncio_Task__repr_info_impl(TaskObj *self);
353
354static PyObject *
355_asyncio_Task__repr_info(TaskObj *self, PyObject *Py_UNUSED(ignored))
356{
357 return _asyncio_Task__repr_info_impl(self);
358}
359
360PyDoc_STRVAR(_asyncio_Task_cancel__doc__,
361"cancel($self, /)\n"
362"--\n"
363"\n"
364"Request that this task cancel itself.\n"
365"\n"
366"This arranges for a CancelledError to be thrown into the\n"
367"wrapped coroutine on the next cycle through the event loop.\n"
368"The coroutine then has a chance to clean up or even deny\n"
369"the request using try/except/finally.\n"
370"\n"
371"Unlike Future.cancel, this does not guarantee that the\n"
372"task will be cancelled: the exception might be caught and\n"
373"acted upon, delaying cancellation of the task or preventing\n"
374"cancellation completely. The task may also return a value or\n"
375"raise a different exception.\n"
376"\n"
377"Immediately after this method is called, Task.cancelled() will\n"
378"not return True (unless the task was already cancelled). A\n"
379"task will be marked as cancelled when the wrapped coroutine\n"
380"terminates with a CancelledError exception (even if cancel()\n"
381"was not called).");
382
383#define _ASYNCIO_TASK_CANCEL_METHODDEF \
384 {"cancel", (PyCFunction)_asyncio_Task_cancel, METH_NOARGS, _asyncio_Task_cancel__doc__},
385
386static PyObject *
387_asyncio_Task_cancel_impl(TaskObj *self);
388
389static PyObject *
390_asyncio_Task_cancel(TaskObj *self, PyObject *Py_UNUSED(ignored))
391{
392 return _asyncio_Task_cancel_impl(self);
393}
394
395PyDoc_STRVAR(_asyncio_Task_get_stack__doc__,
396"get_stack($self, /, *, limit=None)\n"
397"--\n"
398"\n"
399"Return the list of stack frames for this task\'s coroutine.\n"
400"\n"
401"If the coroutine is not done, this returns the stack where it is\n"
402"suspended. If the coroutine has completed successfully or was\n"
403"cancelled, this returns an empty list. If the coroutine was\n"
404"terminated by an exception, this returns the list of traceback\n"
405"frames.\n"
406"\n"
407"The frames are always ordered from oldest to newest.\n"
408"\n"
409"The optional limit gives the maximum number of frames to\n"
410"return; by default all available frames are returned. Its\n"
411"meaning differs depending on whether a stack or a traceback is\n"
412"returned: the newest frames of a stack are returned, but the\n"
413"oldest frames of a traceback are returned. (This matches the\n"
414"behavior of the traceback module.)\n"
415"\n"
416"For reasons beyond our control, only one stack frame is\n"
417"returned for a suspended coroutine.");
418
419#define _ASYNCIO_TASK_GET_STACK_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300420 {"get_stack", (PyCFunction)_asyncio_Task_get_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400421
422static PyObject *
423_asyncio_Task_get_stack_impl(TaskObj *self, PyObject *limit);
424
425static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200426_asyncio_Task_get_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400427{
428 PyObject *return_value = NULL;
429 static const char * const _keywords[] = {"limit", NULL};
430 static _PyArg_Parser _parser = {"|$O:get_stack", _keywords, 0};
431 PyObject *limit = Py_None;
432
Victor Stinner3e1fad62017-01-17 01:29:01 +0100433 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400434 &limit)) {
435 goto exit;
436 }
437 return_value = _asyncio_Task_get_stack_impl(self, limit);
438
439exit:
440 return return_value;
441}
442
443PyDoc_STRVAR(_asyncio_Task_print_stack__doc__,
444"print_stack($self, /, *, limit=None, file=None)\n"
445"--\n"
446"\n"
447"Print the stack or traceback for this task\'s coroutine.\n"
448"\n"
449"This produces output similar to that of the traceback module,\n"
450"for the frames retrieved by get_stack(). The limit argument\n"
451"is passed to get_stack(). The file argument is an I/O stream\n"
452"to which the output is written; by default output is written\n"
453"to sys.stderr.");
454
455#define _ASYNCIO_TASK_PRINT_STACK_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300456 {"print_stack", (PyCFunction)_asyncio_Task_print_stack, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400457
458static PyObject *
459_asyncio_Task_print_stack_impl(TaskObj *self, PyObject *limit,
460 PyObject *file);
461
462static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200463_asyncio_Task_print_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400464{
465 PyObject *return_value = NULL;
466 static const char * const _keywords[] = {"limit", "file", NULL};
467 static _PyArg_Parser _parser = {"|$OO:print_stack", _keywords, 0};
468 PyObject *limit = Py_None;
469 PyObject *file = Py_None;
470
Victor Stinner3e1fad62017-01-17 01:29:01 +0100471 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400472 &limit, &file)) {
473 goto exit;
474 }
475 return_value = _asyncio_Task_print_stack_impl(self, limit, file);
476
477exit:
478 return return_value;
479}
480
481PyDoc_STRVAR(_asyncio_Task__step__doc__,
482"_step($self, /, exc=None)\n"
483"--\n"
484"\n");
485
486#define _ASYNCIO_TASK__STEP_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300487 {"_step", (PyCFunction)_asyncio_Task__step, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task__step__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400488
489static PyObject *
490_asyncio_Task__step_impl(TaskObj *self, PyObject *exc);
491
492static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200493_asyncio_Task__step(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400494{
495 PyObject *return_value = NULL;
496 static const char * const _keywords[] = {"exc", NULL};
497 static _PyArg_Parser _parser = {"|O:_step", _keywords, 0};
Serhiy Storchakabca49392017-09-03 08:10:14 +0300498 PyObject *exc = Py_None;
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400499
Victor Stinner3e1fad62017-01-17 01:29:01 +0100500 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400501 &exc)) {
502 goto exit;
503 }
504 return_value = _asyncio_Task__step_impl(self, exc);
505
506exit:
507 return return_value;
508}
509
510PyDoc_STRVAR(_asyncio_Task__wakeup__doc__,
511"_wakeup($self, /, fut)\n"
512"--\n"
513"\n");
514
515#define _ASYNCIO_TASK__WAKEUP_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300516 {"_wakeup", (PyCFunction)_asyncio_Task__wakeup, METH_FASTCALL|METH_KEYWORDS, _asyncio_Task__wakeup__doc__},
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400517
518static PyObject *
519_asyncio_Task__wakeup_impl(TaskObj *self, PyObject *fut);
520
521static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200522_asyncio_Task__wakeup(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400523{
524 PyObject *return_value = NULL;
525 static const char * const _keywords[] = {"fut", NULL};
526 static _PyArg_Parser _parser = {"O:_wakeup", _keywords, 0};
527 PyObject *fut;
528
Victor Stinner3e1fad62017-01-17 01:29:01 +0100529 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanova0c1ba62016-10-28 12:52:37 -0400530 &fut)) {
531 goto exit;
532 }
533 return_value = _asyncio_Task__wakeup_impl(self, fut);
534
535exit:
536 return return_value;
537}
Yury Selivanova70232f2017-12-13 14:49:42 -0500538
Yury Selivanov0cf16f92017-12-25 10:48:15 -0500539PyDoc_STRVAR(_asyncio_Task_set_result__doc__,
540"set_result($self, result, /)\n"
541"--\n"
542"\n");
543
544#define _ASYNCIO_TASK_SET_RESULT_METHODDEF \
545 {"set_result", (PyCFunction)_asyncio_Task_set_result, METH_O, _asyncio_Task_set_result__doc__},
546
547PyDoc_STRVAR(_asyncio_Task_set_exception__doc__,
548"set_exception($self, exception, /)\n"
549"--\n"
550"\n");
551
552#define _ASYNCIO_TASK_SET_EXCEPTION_METHODDEF \
553 {"set_exception", (PyCFunction)_asyncio_Task_set_exception, METH_O, _asyncio_Task_set_exception__doc__},
554
Yury Selivanova70232f2017-12-13 14:49:42 -0500555PyDoc_STRVAR(_asyncio__get_running_loop__doc__,
556"_get_running_loop($module, /)\n"
557"--\n"
558"\n"
559"Return the running event loop or None.\n"
560"\n"
561"This is a low-level function intended to be used by event loops.\n"
562"This function is thread-specific.");
563
564#define _ASYNCIO__GET_RUNNING_LOOP_METHODDEF \
565 {"_get_running_loop", (PyCFunction)_asyncio__get_running_loop, METH_NOARGS, _asyncio__get_running_loop__doc__},
566
567static PyObject *
568_asyncio__get_running_loop_impl(PyObject *module);
569
570static PyObject *
571_asyncio__get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
572{
573 return _asyncio__get_running_loop_impl(module);
574}
575
576PyDoc_STRVAR(_asyncio__set_running_loop__doc__,
577"_set_running_loop($module, loop, /)\n"
578"--\n"
579"\n"
580"Set the running event loop.\n"
581"\n"
582"This is a low-level function intended to be used by event loops.\n"
583"This function is thread-specific.");
584
585#define _ASYNCIO__SET_RUNNING_LOOP_METHODDEF \
586 {"_set_running_loop", (PyCFunction)_asyncio__set_running_loop, METH_O, _asyncio__set_running_loop__doc__},
587
588PyDoc_STRVAR(_asyncio_get_event_loop__doc__,
589"get_event_loop($module, /)\n"
590"--\n"
591"\n"
592"Return an asyncio event loop.\n"
593"\n"
594"When called from a coroutine or a callback (e.g. scheduled with\n"
595"call_soon or similar API), this function will always return the\n"
596"running event loop.\n"
597"\n"
598"If there is no running event loop set, the function will return\n"
599"the result of `get_event_loop_policy().get_event_loop()` call.");
600
601#define _ASYNCIO_GET_EVENT_LOOP_METHODDEF \
602 {"get_event_loop", (PyCFunction)_asyncio_get_event_loop, METH_NOARGS, _asyncio_get_event_loop__doc__},
603
604static PyObject *
605_asyncio_get_event_loop_impl(PyObject *module);
606
607static PyObject *
608_asyncio_get_event_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
609{
610 return _asyncio_get_event_loop_impl(module);
611}
612
613PyDoc_STRVAR(_asyncio_get_running_loop__doc__,
614"get_running_loop($module, /)\n"
615"--\n"
616"\n"
617"Return the running event loop. Raise a RuntimeError if there is none.\n"
618"\n"
619"This function is thread-specific.");
620
621#define _ASYNCIO_GET_RUNNING_LOOP_METHODDEF \
622 {"get_running_loop", (PyCFunction)_asyncio_get_running_loop, METH_NOARGS, _asyncio_get_running_loop__doc__},
623
624static PyObject *
625_asyncio_get_running_loop_impl(PyObject *module);
626
627static PyObject *
628_asyncio_get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
629{
630 return _asyncio_get_running_loop_impl(module);
631}
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200632
633PyDoc_STRVAR(_asyncio__register_task__doc__,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500634"_register_task($module, /, task)\n"
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200635"--\n"
636"\n"
637"Register a new task in asyncio as executed by loop.\n"
638"\n"
639"Returns None.");
640
641#define _ASYNCIO__REGISTER_TASK_METHODDEF \
642 {"_register_task", (PyCFunction)_asyncio__register_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__},
643
644static PyObject *
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500645_asyncio__register_task_impl(PyObject *module, PyObject *task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200646
647static PyObject *
648_asyncio__register_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
649{
650 PyObject *return_value = NULL;
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500651 static const char * const _keywords[] = {"task", NULL};
652 static _PyArg_Parser _parser = {"O:_register_task", _keywords, 0};
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200653 PyObject *task;
654
655 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500656 &task)) {
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200657 goto exit;
658 }
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500659 return_value = _asyncio__register_task_impl(module, task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200660
661exit:
662 return return_value;
663}
664
665PyDoc_STRVAR(_asyncio__unregister_task__doc__,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500666"_unregister_task($module, /, task)\n"
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200667"--\n"
668"\n"
669"Unregister a task.\n"
670"\n"
671"Returns None.");
672
673#define _ASYNCIO__UNREGISTER_TASK_METHODDEF \
674 {"_unregister_task", (PyCFunction)_asyncio__unregister_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__},
675
676static PyObject *
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500677_asyncio__unregister_task_impl(PyObject *module, PyObject *task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200678
679static PyObject *
680_asyncio__unregister_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
681{
682 PyObject *return_value = NULL;
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500683 static const char * const _keywords[] = {"task", NULL};
684 static _PyArg_Parser _parser = {"O:_unregister_task", _keywords, 0};
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200685 PyObject *task;
686
687 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500688 &task)) {
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200689 goto exit;
690 }
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500691 return_value = _asyncio__unregister_task_impl(module, task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200692
693exit:
694 return return_value;
695}
696
697PyDoc_STRVAR(_asyncio__enter_task__doc__,
698"_enter_task($module, /, loop, task)\n"
699"--\n"
700"\n"
701"Enter into task execution or resume suspended task.\n"
702"\n"
703"Task belongs to loop.\n"
704"\n"
705"Returns None.");
706
707#define _ASYNCIO__ENTER_TASK_METHODDEF \
708 {"_enter_task", (PyCFunction)_asyncio__enter_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__},
709
710static PyObject *
711_asyncio__enter_task_impl(PyObject *module, PyObject *loop, PyObject *task);
712
713static PyObject *
714_asyncio__enter_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
715{
716 PyObject *return_value = NULL;
717 static const char * const _keywords[] = {"loop", "task", NULL};
718 static _PyArg_Parser _parser = {"OO:_enter_task", _keywords, 0};
719 PyObject *loop;
720 PyObject *task;
721
722 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
723 &loop, &task)) {
724 goto exit;
725 }
726 return_value = _asyncio__enter_task_impl(module, loop, task);
727
728exit:
729 return return_value;
730}
731
732PyDoc_STRVAR(_asyncio__leave_task__doc__,
733"_leave_task($module, /, loop, task)\n"
734"--\n"
735"\n"
736"Leave task execution or suspend a task.\n"
737"\n"
738"Task belongs to loop.\n"
739"\n"
740"Returns None.");
741
742#define _ASYNCIO__LEAVE_TASK_METHODDEF \
743 {"_leave_task", (PyCFunction)_asyncio__leave_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__},
744
745static PyObject *
746_asyncio__leave_task_impl(PyObject *module, PyObject *loop, PyObject *task);
747
748static PyObject *
749_asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
750{
751 PyObject *return_value = NULL;
752 static const char * const _keywords[] = {"loop", "task", NULL};
753 static _PyArg_Parser _parser = {"OO:_leave_task", _keywords, 0};
754 PyObject *loop;
755 PyObject *task;
756
757 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
758 &loop, &task)) {
759 goto exit;
760 }
761 return_value = _asyncio__leave_task_impl(module, loop, task);
762
763exit:
764 return return_value;
765}
Yury Selivanov0cf16f92017-12-25 10:48:15 -0500766/*[clinic end generated code: output=616e814431893dcc input=a9049054013a1b77]*/