conc.py 文件源码

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

项目:deco 作者: alex-sherman 项目源码 文件源码
def __call__(self, *args, **kwargs):
        if self.f is None:
            source = inspect.getsourcelines(self.orig_f)[0]
            astutil.unindent(source)
            source = "".join(source)
            self.ast = ast.parse(source)
            rewriter = astutil.SchedulerRewriter(concurrent.functions.keys(), self.frame_info)
            rewriter.visit(self.ast.body[0])
            ast.fix_missing_locations(self.ast)
            out = compile(self.ast, "<string>", "exec")
            scope = dict(self.orig_f.__globals__)
            exec(out, scope)
            self.f = scope[self.orig_f.__name__]
        return self.f(*args, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号