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)
评论列表
文章目录