summaryrefslogtreecommitdiff
path: root/smart_future.py
diff options
context:
space:
mode:
Diffstat (limited to 'smart_future.py')
-rw-r--r--smart_future.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/smart_future.py b/smart_future.py
index 1c95973..7dbec50 100644
--- a/smart_future.py
+++ b/smart_future.py
@@ -36,6 +36,16 @@ def wait_any(futures: List[SmartFuture], *, callback: Callable = None):
return
+def wait_all(futures: List[SmartFuture]) -> None:
+ done_set = set()
+ while len(done_set) < len(futures):
+ for future in futures:
+ i = future.get_id()
+ if i not in done_set and future.wrapped_future.done():
+ done_set.add(i)
+ time.sleep(0.1)
+
+
class SmartFuture(DeferredOperand):
"""This is a SmartFuture, a class that wraps a normal Future and can
then be used, mostly, like a normal (non-Future) identifier.