blob: 6a35434ce3ba5c7caf71edd5ba60fe895eaeb538 [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__,
89"set_result($self, res, /)\n"
90"--\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
539PyDoc_STRVAR(_asyncio__get_running_loop__doc__,
540"_get_running_loop($module, /)\n"
541"--\n"
542"\n"
543"Return the running event loop or None.\n"
544"\n"
545"This is a low-level function intended to be used by event loops.\n"
546"This function is thread-specific.");
547
548#define _ASYNCIO__GET_RUNNING_LOOP_METHODDEF \
549 {"_get_running_loop", (PyCFunction)_asyncio__get_running_loop, METH_NOARGS, _asyncio__get_running_loop__doc__},
550
551static PyObject *
552_asyncio__get_running_loop_impl(PyObject *module);
553
554static PyObject *
555_asyncio__get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
556{
557 return _asyncio__get_running_loop_impl(module);
558}
559
560PyDoc_STRVAR(_asyncio__set_running_loop__doc__,
561"_set_running_loop($module, loop, /)\n"
562"--\n"
563"\n"
564"Set the running event loop.\n"
565"\n"
566"This is a low-level function intended to be used by event loops.\n"
567"This function is thread-specific.");
568
569#define _ASYNCIO__SET_RUNNING_LOOP_METHODDEF \
570 {"_set_running_loop", (PyCFunction)_asyncio__set_running_loop, METH_O, _asyncio__set_running_loop__doc__},
571
572PyDoc_STRVAR(_asyncio_get_event_loop__doc__,
573"get_event_loop($module, /)\n"
574"--\n"
575"\n"
576"Return an asyncio event loop.\n"
577"\n"
578"When called from a coroutine or a callback (e.g. scheduled with\n"
579"call_soon or similar API), this function will always return the\n"
580"running event loop.\n"
581"\n"
582"If there is no running event loop set, the function will return\n"
583"the result of `get_event_loop_policy().get_event_loop()` call.");
584
585#define _ASYNCIO_GET_EVENT_LOOP_METHODDEF \
586 {"get_event_loop", (PyCFunction)_asyncio_get_event_loop, METH_NOARGS, _asyncio_get_event_loop__doc__},
587
588static PyObject *
589_asyncio_get_event_loop_impl(PyObject *module);
590
591static PyObject *
592_asyncio_get_event_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
593{
594 return _asyncio_get_event_loop_impl(module);
595}
596
597PyDoc_STRVAR(_asyncio_get_running_loop__doc__,
598"get_running_loop($module, /)\n"
599"--\n"
600"\n"
601"Return the running event loop. Raise a RuntimeError if there is none.\n"
602"\n"
603"This function is thread-specific.");
604
605#define _ASYNCIO_GET_RUNNING_LOOP_METHODDEF \
606 {"get_running_loop", (PyCFunction)_asyncio_get_running_loop, METH_NOARGS, _asyncio_get_running_loop__doc__},
607
608static PyObject *
609_asyncio_get_running_loop_impl(PyObject *module);
610
611static PyObject *
612_asyncio_get_running_loop(PyObject *module, PyObject *Py_UNUSED(ignored))
613{
614 return _asyncio_get_running_loop_impl(module);
615}
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200616
617PyDoc_STRVAR(_asyncio__register_task__doc__,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500618"_register_task($module, /, task)\n"
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200619"--\n"
620"\n"
621"Register a new task in asyncio as executed by loop.\n"
622"\n"
623"Returns None.");
624
625#define _ASYNCIO__REGISTER_TASK_METHODDEF \
626 {"_register_task", (PyCFunction)_asyncio__register_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__register_task__doc__},
627
628static PyObject *
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500629_asyncio__register_task_impl(PyObject *module, PyObject *task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200630
631static PyObject *
632_asyncio__register_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
633{
634 PyObject *return_value = NULL;
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500635 static const char * const _keywords[] = {"task", NULL};
636 static _PyArg_Parser _parser = {"O:_register_task", _keywords, 0};
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200637 PyObject *task;
638
639 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500640 &task)) {
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200641 goto exit;
642 }
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500643 return_value = _asyncio__register_task_impl(module, task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200644
645exit:
646 return return_value;
647}
648
649PyDoc_STRVAR(_asyncio__unregister_task__doc__,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500650"_unregister_task($module, /, task)\n"
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200651"--\n"
652"\n"
653"Unregister a task.\n"
654"\n"
655"Returns None.");
656
657#define _ASYNCIO__UNREGISTER_TASK_METHODDEF \
658 {"_unregister_task", (PyCFunction)_asyncio__unregister_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__unregister_task__doc__},
659
660static PyObject *
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500661_asyncio__unregister_task_impl(PyObject *module, PyObject *task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200662
663static PyObject *
664_asyncio__unregister_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
665{
666 PyObject *return_value = NULL;
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500667 static const char * const _keywords[] = {"task", NULL};
668 static _PyArg_Parser _parser = {"O:_unregister_task", _keywords, 0};
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200669 PyObject *task;
670
671 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500672 &task)) {
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200673 goto exit;
674 }
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500675 return_value = _asyncio__unregister_task_impl(module, task);
Andrew Svetlov44d1a592017-12-16 21:58:38 +0200676
677exit:
678 return return_value;
679}
680
681PyDoc_STRVAR(_asyncio__enter_task__doc__,
682"_enter_task($module, /, loop, task)\n"
683"--\n"
684"\n"
685"Enter into task execution or resume suspended task.\n"
686"\n"
687"Task belongs to loop.\n"
688"\n"
689"Returns None.");
690
691#define _ASYNCIO__ENTER_TASK_METHODDEF \
692 {"_enter_task", (PyCFunction)_asyncio__enter_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__enter_task__doc__},
693
694static PyObject *
695_asyncio__enter_task_impl(PyObject *module, PyObject *loop, PyObject *task);
696
697static PyObject *
698_asyncio__enter_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
699{
700 PyObject *return_value = NULL;
701 static const char * const _keywords[] = {"loop", "task", NULL};
702 static _PyArg_Parser _parser = {"OO:_enter_task", _keywords, 0};
703 PyObject *loop;
704 PyObject *task;
705
706 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
707 &loop, &task)) {
708 goto exit;
709 }
710 return_value = _asyncio__enter_task_impl(module, loop, task);
711
712exit:
713 return return_value;
714}
715
716PyDoc_STRVAR(_asyncio__leave_task__doc__,
717"_leave_task($module, /, loop, task)\n"
718"--\n"
719"\n"
720"Leave task execution or suspend a task.\n"
721"\n"
722"Task belongs to loop.\n"
723"\n"
724"Returns None.");
725
726#define _ASYNCIO__LEAVE_TASK_METHODDEF \
727 {"_leave_task", (PyCFunction)_asyncio__leave_task, METH_FASTCALL|METH_KEYWORDS, _asyncio__leave_task__doc__},
728
729static PyObject *
730_asyncio__leave_task_impl(PyObject *module, PyObject *loop, PyObject *task);
731
732static PyObject *
733_asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
734{
735 PyObject *return_value = NULL;
736 static const char * const _keywords[] = {"loop", "task", NULL};
737 static _PyArg_Parser _parser = {"OO:_leave_task", _keywords, 0};
738 PyObject *loop;
739 PyObject *task;
740
741 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
742 &loop, &task)) {
743 goto exit;
744 }
745 return_value = _asyncio__leave_task_impl(module, loop, task);
746
747exit:
748 return return_value;
749}
Yury Selivanovca9b36c2017-12-23 15:04:15 -0500750/*[clinic end generated code: output=5d100b3d74f2a0f4 input=a9049054013a1b77]*/