executor.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:makiki 作者: faith0811 项目源码 文件源码
def __call__(self, func):
        func_logger = logging.getLogger(func.__module__)

        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            start = time.time()
            request = kwargs.get('request')
            if request:
                _of = getattr(func, 'original', func)
                if 'request' not in _of.__code__.co_varnames:
                    del kwargs['request']
            response = kwargs.get('response')
            if response:
                _of = getattr(func, 'original', func)
                if 'response' not in _of.__code__.co_varnames:
                    del kwargs['response']
            try:
                if self.timeout:
                    with gevent.Timeout(self.timeout):
                        return self._process(func, args, kwargs, request, response)
                else:
                    return self._process(func, args, kwargs, request, response)

            except falcon.http_status.HTTPStatus:
                raise
            except Exception as e:
                return self._process_exception_output(e, func_logger, request, response, args, kwargs)
            finally:
                execution_time = (time.time() - start) * 1000
                self._finish_exec(execution_time, func_logger, args, kwargs, request, func)
        return self._gevent_wrapper(wrapper)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号