main.py 文件源码

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

项目:inmanta 作者: inmanta 项目源码 文件源码
def run_sync(self, func):
        if self._own_loop:
            return self._io_loop.run_sync(func)

        else:
            f = Future()

            def future_to_future(future):
                exc = future.exception()
                if exc is not None:
                    f.set_exception(exc)
                else:
                    f.set_result(future.result())

            def run():
                try:
                    result = func()
                    if result is not None:
                        from tornado.gen import convert_yielded
                        result = convert_yielded(result)
                        result.add_done_callback(future_to_future)
                except Exception as e:
                    f.set_exception(e)
            self._io_loop.add_callback(run)

            return f.result()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号