concurrency.py 文件源码

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

项目:easypy 作者: weka-io 项目源码 文件源码
def concurrent_find(func, params, **kw):
    timeout = kw.pop("concurrent_timeout", None)
    with async(func, list(params), **kw) as futures:
        future = None
        try:
            for future in futures.as_completed(timeout=timeout):
                if not future.exception() and future.result():
                    futures.kill()
                    return future.result()
            else:
                if future:
                    return future.result()
        except FutureTimeoutError as exc:
            if not timeout:
                # ??
                raise
            futures.kill()
            _logger.warning("Concurrent future timed out (%s)", exc)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号