Fix async generator shutdowner

This commit is contained in:
Roman Mogylatov 2020-11-18 14:48:05 -05:00
parent e9344905fe
commit 1aadb1a3cb
2 changed files with 10 additions and 7 deletions

View File

@ -3176,6 +3176,7 @@ static const char __pyx_k_Error[] = "Error";
static const char __pyx_k_False[] = "False"; static const char __pyx_k_False[] = "False";
static const char __pyx_k_RLock[] = "RLock"; static const char __pyx_k_RLock[] = "RLock";
static const char __pyx_k_anext[] = "__anext__"; static const char __pyx_k_anext[] = "__anext__";
static const char __pyx_k_asend[] = "asend";
static const char __pyx_k_class[] = "__class__"; static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_close[] = "close"; static const char __pyx_k_close[] = "close";
static const char __pyx_k_dict1[] = "dict1"; static const char __pyx_k_dict1[] = "dict1";
@ -3643,6 +3644,7 @@ static PyObject *__pyx_n_s_add_sys_streams;
static PyObject *__pyx_n_s_address; static PyObject *__pyx_n_s_address;
static PyObject *__pyx_n_s_anext; static PyObject *__pyx_n_s_anext;
static PyObject *__pyx_n_s_args; static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_asend;
static PyObject *__pyx_n_s_asyncio; static PyObject *__pyx_n_s_asyncio;
static PyObject *__pyx_n_s_asyncio_coroutines; static PyObject *__pyx_n_s_asyncio_coroutines;
static PyObject *__pyx_n_s_asyncio_tasks; static PyObject *__pyx_n_s_asyncio_tasks;
@ -49437,7 +49439,7 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
* self.__kwargs_len, * self.__kwargs_len,
* ) * )
* self.__resource = loop.run_until_complete(initializer.__anext__()) # <<<<<<<<<<<<<< * self.__resource = loop.run_until_complete(initializer.__anext__()) # <<<<<<<<<<<<<<
* self.__shutdowner = initializer.__anext__ * self.__shutdowner = initializer.asend
* elif inspect.isfunction(self.__initializer): * elif inspect.isfunction(self.__initializer):
*/ */
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_loop, __pyx_n_s_run_until_complete); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2780, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_loop, __pyx_n_s_run_until_complete); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2780, __pyx_L1_error)
@ -49484,11 +49486,11 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
/* "dependency_injector/providers.pyx":2781 /* "dependency_injector/providers.pyx":2781
* ) * )
* self.__resource = loop.run_until_complete(initializer.__anext__()) * self.__resource = loop.run_until_complete(initializer.__anext__())
* self.__shutdowner = initializer.__anext__ # <<<<<<<<<<<<<< * self.__shutdowner = initializer.asend # <<<<<<<<<<<<<<
* elif inspect.isfunction(self.__initializer): * elif inspect.isfunction(self.__initializer):
* self.__resource = __call( * self.__resource = __call(
*/ */
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_initializer, __pyx_n_s_anext); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2781, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_initializer, __pyx_n_s_asend); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2781, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4);
__Pyx_GOTREF(__pyx_v_self->__pyx___shutdowner); __Pyx_GOTREF(__pyx_v_self->__pyx___shutdowner);
@ -49508,7 +49510,7 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
/* "dependency_injector/providers.pyx":2782 /* "dependency_injector/providers.pyx":2782
* self.__resource = loop.run_until_complete(initializer.__anext__()) * self.__resource = loop.run_until_complete(initializer.__anext__())
* self.__shutdowner = initializer.__anext__ * self.__shutdowner = initializer.asend
* elif inspect.isfunction(self.__initializer): # <<<<<<<<<<<<<< * elif inspect.isfunction(self.__initializer): # <<<<<<<<<<<<<<
* self.__resource = __call( * self.__resource = __call(
* self.__initializer, * self.__initializer,
@ -49568,7 +49570,7 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
__Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_2);
/* "dependency_injector/providers.pyx":2783 /* "dependency_injector/providers.pyx":2783
* self.__shutdowner = initializer.__anext__ * self.__shutdowner = initializer.asend
* elif inspect.isfunction(self.__initializer): * elif inspect.isfunction(self.__initializer):
* self.__resource = __call( # <<<<<<<<<<<<<< * self.__resource = __call( # <<<<<<<<<<<<<<
* self.__initializer, * self.__initializer,
@ -49587,7 +49589,7 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
/* "dependency_injector/providers.pyx":2782 /* "dependency_injector/providers.pyx":2782
* self.__resource = loop.run_until_complete(initializer.__anext__()) * self.__resource = loop.run_until_complete(initializer.__anext__())
* self.__shutdowner = initializer.__anext__ * self.__shutdowner = initializer.asend
* elif inspect.isfunction(self.__initializer): # <<<<<<<<<<<<<< * elif inspect.isfunction(self.__initializer): # <<<<<<<<<<<<<<
* self.__resource = __call( * self.__resource = __call(
* self.__initializer, * self.__initializer,
@ -91507,6 +91509,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s_address, __pyx_k_address, sizeof(__pyx_k_address), 0, 0, 1, 1}, {&__pyx_n_s_address, __pyx_k_address, sizeof(__pyx_k_address), 0, 0, 1, 1},
{&__pyx_n_s_anext, __pyx_k_anext, sizeof(__pyx_k_anext), 0, 0, 1, 1}, {&__pyx_n_s_anext, __pyx_k_anext, sizeof(__pyx_k_anext), 0, 0, 1, 1},
{&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
{&__pyx_n_s_asend, __pyx_k_asend, sizeof(__pyx_k_asend), 0, 0, 1, 1},
{&__pyx_n_s_asyncio, __pyx_k_asyncio, sizeof(__pyx_k_asyncio), 0, 0, 1, 1}, {&__pyx_n_s_asyncio, __pyx_k_asyncio, sizeof(__pyx_k_asyncio), 0, 0, 1, 1},
{&__pyx_n_s_asyncio_coroutines, __pyx_k_asyncio_coroutines, sizeof(__pyx_k_asyncio_coroutines), 0, 0, 1, 1}, {&__pyx_n_s_asyncio_coroutines, __pyx_k_asyncio_coroutines, sizeof(__pyx_k_asyncio_coroutines), 0, 0, 1, 1},
{&__pyx_n_s_asyncio_tasks, __pyx_k_asyncio_tasks, sizeof(__pyx_k_asyncio_tasks), 0, 0, 1, 1}, {&__pyx_n_s_asyncio_tasks, __pyx_k_asyncio_tasks, sizeof(__pyx_k_asyncio_tasks), 0, 0, 1, 1},

View File

@ -2778,7 +2778,7 @@ cdef class Resource(Provider):
self.__kwargs_len, self.__kwargs_len,
) )
self.__resource = loop.run_until_complete(initializer.__anext__()) self.__resource = loop.run_until_complete(initializer.__anext__())
self.__shutdowner = initializer.__anext__ self.__shutdowner = initializer.asend
elif inspect.isfunction(self.__initializer): elif inspect.isfunction(self.__initializer):
self.__resource = __call( self.__resource = __call(
self.__initializer, self.__initializer,