file_watch.py 文件源码

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

项目:kingpin 作者: pinterest 项目源码 文件源码
def timeout_after(secs):
    """Decorator to timeout a function.

    It raises a gevent.Timeout exception after the specified seconds in
    the decorated function. The timeout will work only if the decorated
    function yields, e.g. performing blocking operations through gevent.

    """
    def timeout_enforced(f):
        @wraps(f)
        def g(*args, **kwargs):
            return gevent.with_timeout(secs, f, *args, **kwargs)
        return g
    return timeout_enforced
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号