X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=smart_future.py;h=7dbec5004b4ba927331e71fb812fd482af678c3c;hb=37d09d6ac30c8c66477149b7c73139c3e6782468;hp=1c95973f48ab3bc3a0c9bcd90fa13498f851b8a9;hpb=09e6d10face80d98a4578ff54192b5c8bec007d7;p=python_utils.git 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.