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