mc_neighbors.py 文件源码

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

项目:mediachain-indexer 作者: mediachain 项目源码 文件源码
def fake_async_decorator(ocls):
    """
    Wrap all non-private methods of a class with the tornado Task decorator.

    Used to simulate the interface of async methods, but with methods that actually block.

    TODO: Test.
    """
    import tornado
    import tornado.gen

    cls = type(ocls.__name__ + 'Async', ocls.__bases__, dict(ocls.__dict__))

    for attr in cls.__dict__:
        if callable(getattr(cls, attr)) and (not attr.startswith('_')):

            def fake(*args, **kw):
                yield tornado.gen.Task(getattr(cls, attr)(*args, **kw))

            setattr(cls, attr, fake)

    return cls
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号