Various changes.
[python_utils.git] / smart_future.py
index 1c95973f48ab3bc3a0c9bcd90fa13498f851b8a9..7dbec5004b4ba927331e71fb812fd482af678c3c 100644 (file)
@@ -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.