diff options
Diffstat (limited to 'Modules/_asynciomodule.c')
| -rw-r--r-- | Modules/_asynciomodule.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 01e36c656d..a4d5d4551e 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -319,7 +319,7 @@ set_running_loop(PyObject *loop) static PyObject * -get_event_loop(void) +get_event_loop(int stacklevel) { PyObject *loop; PyObject *policy; @@ -331,6 +331,13 @@ get_event_loop(void) return loop; } + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "There is no current event loop", + stacklevel)) + { + return NULL; + } + policy = PyObject_CallNoArgs(asyncio_get_event_loop_policy); if (policy == NULL) { return NULL; @@ -489,7 +496,7 @@ future_init(FutureObj *fut, PyObject *loop) fut->fut_blocking = 0; if (loop == Py_None) { - loop = get_event_loop(); + loop = get_event_loop(1); if (loop == NULL) { return -1; } @@ -3078,7 +3085,19 @@ static PyObject * _asyncio_get_event_loop_impl(PyObject *module) /*[clinic end generated code: output=2a2d8b2f824c648b input=9364bf2916c8655d]*/ { - return get_event_loop(); + return get_event_loop(1); +} + +/*[clinic input] +_asyncio._get_event_loop + stacklevel: int = 3 +[clinic start generated code]*/ + +static PyObject * +_asyncio__get_event_loop_impl(PyObject *module, int stacklevel) +/*[clinic end generated code: output=9c1d6d3c802e67c9 input=d17aebbd686f711d]*/ +{ + return get_event_loop(stacklevel-1); } /*[clinic input] @@ -3375,6 +3394,7 @@ PyDoc_STRVAR(module_doc, "Accelerator module for asyncio"); static PyMethodDef asyncio_methods[] = { _ASYNCIO_GET_EVENT_LOOP_METHODDEF + _ASYNCIO__GET_EVENT_LOOP_METHODDEF _ASYNCIO_GET_RUNNING_LOOP_METHODDEF _ASYNCIO__GET_RUNNING_LOOP_METHODDEF _ASYNCIO__SET_RUNNING_LOOP_METHODDEF |
