Skip to content

Instantly share code, notes, and snippets.

View Klotzi111's full-sized avatar

Klotzi111

  • Germany
  • 20:35 (UTC +01:00)
View GitHub Profile
@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.