mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-04 12:23:14 +03:00
Improve resource initializer types selector
This commit is contained in:
parent
ce800aa6d4
commit
11b251ba4d
|
@ -3290,6 +3290,7 @@ static const char __pyx_k_before_get[] = "before_get";
|
|||
static const char __pyx_k_clear_args[] = "clear_args";
|
||||
static const char __pyx_k_coroutines[] = "coroutines";
|
||||
static const char __pyx_k_expandvars[] = "expandvars";
|
||||
static const char __pyx_k_isfunction[] = "isfunction";
|
||||
static const char __pyx_k_overridden[] = "overridden";
|
||||
static const char __pyx_k_overriding[] = "overriding";
|
||||
static const char __pyx_k_pyx_result[] = "__pyx_result";
|
||||
|
@ -3724,6 +3725,7 @@ static PyObject *__pyx_n_s_is_coroutine_marker;
|
|||
static PyObject *__pyx_n_s_is_resource_subclass;
|
||||
static PyObject *__pyx_n_s_isasyncgenfunction;
|
||||
static PyObject *__pyx_n_s_iscoroutinefunction;
|
||||
static PyObject *__pyx_n_s_isfunction;
|
||||
static PyObject *__pyx_n_s_isgeneratorfunction;
|
||||
static PyObject *__pyx_n_s_item;
|
||||
static PyObject *__pyx_n_s_items;
|
||||
|
@ -48639,7 +48641,6 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
|
|||
PyObject *__pyx_t_6 = NULL;
|
||||
int __pyx_t_7;
|
||||
PyObject *__pyx_t_8 = NULL;
|
||||
int __pyx_t_9;
|
||||
int __pyx_lineno = 0;
|
||||
const char *__pyx_filename = NULL;
|
||||
int __pyx_clineno = 0;
|
||||
|
@ -49437,7 +49438,7 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
|
|||
* )
|
||||
* self.__resource = loop.run_until_complete(initializer.__anext__()) # <<<<<<<<<<<<<<
|
||||
* self.__shutdowner = initializer.__anext__
|
||||
* elif callable(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_GOTREF(__pyx_t_2);
|
||||
|
@ -49484,7 +49485,7 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
|
|||
* )
|
||||
* self.__resource = loop.run_until_complete(initializer.__anext__())
|
||||
* self.__shutdowner = initializer.__anext__ # <<<<<<<<<<<<<<
|
||||
* elif callable(self.__initializer):
|
||||
* elif inspect.isfunction(self.__initializer):
|
||||
* 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)
|
||||
|
@ -49508,19 +49509,36 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
|
|||
/* "dependency_injector/providers.pyx":2782
|
||||
* self.__resource = loop.run_until_complete(initializer.__anext__())
|
||||
* self.__shutdowner = initializer.__anext__
|
||||
* elif callable(self.__initializer): # <<<<<<<<<<<<<<
|
||||
* elif inspect.isfunction(self.__initializer): # <<<<<<<<<<<<<<
|
||||
* self.__resource = __call(
|
||||
* self.__initializer,
|
||||
*/
|
||||
__pyx_t_4 = __pyx_v_self->__pyx___initializer;
|
||||
__Pyx_INCREF(__pyx_t_4);
|
||||
__pyx_t_7 = __Pyx_PyCallable_Check(__pyx_t_4); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(1, 2782, __pyx_L1_error)
|
||||
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_inspect); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2782, __pyx_L1_error)
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isfunction); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2782, __pyx_L1_error)
|
||||
__Pyx_GOTREF(__pyx_t_8);
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
__pyx_t_2 = NULL;
|
||||
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
|
||||
__pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
|
||||
if (likely(__pyx_t_2)) {
|
||||
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
|
||||
__Pyx_INCREF(__pyx_t_2);
|
||||
__Pyx_INCREF(function);
|
||||
__Pyx_DECREF_SET(__pyx_t_8, function);
|
||||
}
|
||||
}
|
||||
__pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_2, __pyx_v_self->__pyx___initializer) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_self->__pyx___initializer);
|
||||
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2782, __pyx_L1_error)
|
||||
__Pyx_GOTREF(__pyx_t_4);
|
||||
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
|
||||
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(1, 2782, __pyx_L1_error)
|
||||
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
|
||||
__pyx_t_9 = (__pyx_t_7 != 0);
|
||||
if (likely(__pyx_t_9)) {
|
||||
if (likely(__pyx_t_7)) {
|
||||
|
||||
/* "dependency_injector/providers.pyx":2784
|
||||
* elif callable(self.__initializer):
|
||||
* elif inspect.isfunction(self.__initializer):
|
||||
* self.__resource = __call(
|
||||
* self.__initializer, # <<<<<<<<<<<<<<
|
||||
* args,
|
||||
|
@ -49536,8 +49554,8 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
|
|||
* self.__args_len,
|
||||
* kwargs,
|
||||
*/
|
||||
__pyx_t_2 = __pyx_v_self->__pyx___args;
|
||||
__Pyx_INCREF(__pyx_t_2);
|
||||
__pyx_t_8 = __pyx_v_self->__pyx___args;
|
||||
__Pyx_INCREF(__pyx_t_8);
|
||||
|
||||
/* "dependency_injector/providers.pyx":2789
|
||||
* self.__args_len,
|
||||
|
@ -49546,21 +49564,21 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
|
|||
* self.__kwargs_len,
|
||||
* )
|
||||
*/
|
||||
__pyx_t_8 = __pyx_v_self->__pyx___kwargs;
|
||||
__Pyx_INCREF(__pyx_t_8);
|
||||
__pyx_t_2 = __pyx_v_self->__pyx___kwargs;
|
||||
__Pyx_INCREF(__pyx_t_2);
|
||||
|
||||
/* "dependency_injector/providers.pyx":2783
|
||||
* self.__shutdowner = initializer.__anext__
|
||||
* elif callable(self.__initializer):
|
||||
* elif inspect.isfunction(self.__initializer):
|
||||
* self.__resource = __call( # <<<<<<<<<<<<<<
|
||||
* self.__initializer,
|
||||
* args,
|
||||
*/
|
||||
__pyx_t_6 = __pyx_f_19dependency_injector_9providers___call(__pyx_t_4, __pyx_v_args, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___args_len, __pyx_v_kwargs, ((PyObject*)__pyx_t_8), __pyx_v_self->__pyx___kwargs_len); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2783, __pyx_L1_error)
|
||||
__pyx_t_6 = __pyx_f_19dependency_injector_9providers___call(__pyx_t_4, __pyx_v_args, ((PyObject*)__pyx_t_8), __pyx_v_self->__pyx___args_len, __pyx_v_kwargs, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___kwargs_len); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2783, __pyx_L1_error)
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
__Pyx_GIVEREF(__pyx_t_6);
|
||||
__Pyx_GOTREF(__pyx_v_self->__pyx___resource);
|
||||
__Pyx_DECREF(__pyx_v_self->__pyx___resource);
|
||||
|
@ -49570,7 +49588,7 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
|
|||
/* "dependency_injector/providers.pyx":2782
|
||||
* self.__resource = loop.run_until_complete(initializer.__anext__())
|
||||
* self.__shutdowner = initializer.__anext__
|
||||
* elif callable(self.__initializer): # <<<<<<<<<<<<<<
|
||||
* elif inspect.isfunction(self.__initializer): # <<<<<<<<<<<<<<
|
||||
* self.__resource = __call(
|
||||
* self.__initializer,
|
||||
*/
|
||||
|
@ -49585,23 +49603,23 @@ static PyObject *__pyx_f_19dependency_injector_9providers_8Resource__provide(str
|
|||
* self.__initialized = True
|
||||
*/
|
||||
/*else*/ {
|
||||
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_Error); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2793, __pyx_L1_error)
|
||||
__Pyx_GOTREF(__pyx_t_8);
|
||||
__pyx_t_2 = NULL;
|
||||
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
|
||||
__pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
|
||||
if (likely(__pyx_t_2)) {
|
||||
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
|
||||
__Pyx_INCREF(__pyx_t_2);
|
||||
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Error); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2793, __pyx_L1_error)
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_8 = NULL;
|
||||
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
|
||||
__pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
|
||||
if (likely(__pyx_t_8)) {
|
||||
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
|
||||
__Pyx_INCREF(__pyx_t_8);
|
||||
__Pyx_INCREF(function);
|
||||
__Pyx_DECREF_SET(__pyx_t_8, function);
|
||||
__Pyx_DECREF_SET(__pyx_t_2, function);
|
||||
}
|
||||
}
|
||||
__pyx_t_6 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_2, __pyx_kp_s_Unknown_type_of_resource_initial) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_kp_s_Unknown_type_of_resource_initial);
|
||||
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
__pyx_t_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_8, __pyx_kp_s_Unknown_type_of_resource_initial) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s_Unknown_type_of_resource_initial);
|
||||
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
|
||||
if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2793, __pyx_L1_error)
|
||||
__Pyx_GOTREF(__pyx_t_6);
|
||||
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
__Pyx_Raise(__pyx_t_6, 0, 0, 0);
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__PYX_ERR(1, 2793, __pyx_L1_error)
|
||||
|
@ -91571,6 +91589,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
|
|||
{&__pyx_n_s_is_resource_subclass, __pyx_k_is_resource_subclass, sizeof(__pyx_k_is_resource_subclass), 0, 0, 1, 1},
|
||||
{&__pyx_n_s_isasyncgenfunction, __pyx_k_isasyncgenfunction, sizeof(__pyx_k_isasyncgenfunction), 0, 0, 1, 1},
|
||||
{&__pyx_n_s_iscoroutinefunction, __pyx_k_iscoroutinefunction, sizeof(__pyx_k_iscoroutinefunction), 0, 0, 1, 1},
|
||||
{&__pyx_n_s_isfunction, __pyx_k_isfunction, sizeof(__pyx_k_isfunction), 0, 0, 1, 1},
|
||||
{&__pyx_n_s_isgeneratorfunction, __pyx_k_isgeneratorfunction, sizeof(__pyx_k_isgeneratorfunction), 0, 0, 1, 1},
|
||||
{&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
|
||||
{&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
|
||||
|
|
|
@ -2779,7 +2779,7 @@ cdef class Resource(Provider):
|
|||
)
|
||||
self.__resource = loop.run_until_complete(initializer.__anext__())
|
||||
self.__shutdowner = initializer.__anext__
|
||||
elif callable(self.__initializer):
|
||||
elif inspect.isfunction(self.__initializer):
|
||||
self.__resource = __call(
|
||||
self.__initializer,
|
||||
args,
|
||||
|
|
Loading…
Reference in New Issue
Block a user