Skip to content
Snippets Groups Projects
Commit 75ff7625 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

add exc

parent dff252da
No related branches found
No related tags found
No related merge requests found
import typing as tp
from concurrent.futures import Future
from satella.exceptions import WouldWaitMore
class FutureCollection:
"""
......@@ -98,15 +100,21 @@ class FutureCollection:
for future in self.futures:
future.set_exception(exc)
def result(self) -> list:
def result(self, timeout: tp.Optional[float] = None) -> list:
"""
Return the result of all futures, as a list.
This will block until the results are available.
:param timeout: a timeout for a single result. Default value None means
wait as long as necessary
:return: list containing results of all futures
:raises WouldWaitMore: timeout while waiting for result
"""
return [fut.result() for fut in self.futures]
try:
return [fut.result() for fut in self.futures]
except TimeoutError:
raise WouldWaitMore()
def cancel(self) -> bool:
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment