Skip to content

Instantly share code, notes, and snippets.

@Klotzi111
Klotzi111 / combined_future.py
Last active November 16, 2023 00:19
Python CombinedFuture
import concurrent
from concurrent.futures import Future
from typing import Any
class CombinedFuture(Future[Future | None]):
"""
This class provides "waiting" mechanisms similar to concurrent.futures.wait(...) except that there is no blocking wait.
This class extends concurrent.futures.Future and thus it can be used like any other Future.
You can use the .result() and .done() (and other) methods and also use this class with the aforementioned concurrent.futures.wait function.