Message343084
Thank you very much for raising the question.
@patch(...) creates _patch class instance.
For decoration _patch.__call__ is used.
def __call__(self, func):
if isinstance(func, type):
return self.decorate_class(func)
return self.decorate_callable(func)
The code can be modified to
def __call__(self, func):
if isinstance(func, type):
return self.decorate_class(func)
if inspect.iscoroutinefunction(func):
return self.decorate_async_func(func)
return self.decorate_callable(func)
decorate_async_func can do all the same as decorate_callable with the only difference: internal
@wraps(func)
def patched(*args, **keywargs):
should be replaced with
@wraps(func)
async def patched(*args, **keywargs):
and
return func(*args, **keywargs)
replaced with
return await func(*args, **keywargs)
Pretty straightforward.
I did not check the code though.
I'm pretty busy up to 3.8 feature freeze to make the PR for proposed change but I love to review the existing patch.
Do want somebody to be a champion? |
|
Date |
User |
Action |
Args |
2019-05-21 19:06:31 | asvetlov | set | recipients:
+ asvetlov, cjw296, michael.foord, yselivanov, lisroach, xtreak |
2019-05-21 19:06:31 | asvetlov | set | messageid: <1558465591.83.0.459020555027.issue36996@roundup.psfhosted.org> |
2019-05-21 19:06:31 | asvetlov | link | issue36996 messages |
2019-05-21 19:06:31 | asvetlov | create | |
|