diff --git a/bdai_ros2_wrappers/bdai_ros2_wrappers/futures.py b/bdai_ros2_wrappers/bdai_ros2_wrappers/futures.py index 0d72de0..d68ed82 100644 --- a/bdai_ros2_wrappers/bdai_ros2_wrappers/futures.py +++ b/bdai_ros2_wrappers/bdai_ros2_wrappers/futures.py @@ -8,7 +8,6 @@ T = TypeVar("T", covariant=True) -@runtime_checkable class FutureLike(Awaitable[T], Protocol[T]): """A future-like awaitable object. @@ -40,6 +39,7 @@ def cancelled(self) -> bool: ... +@runtime_checkable class FutureConvertible(Awaitable[T], Protocol[T]): """An awaitable that is convertible to a future-like object.""" @@ -53,9 +53,9 @@ def as_future(self) -> FutureLike[T]: def as_proper_future(instance: AnyFuture) -> FutureLike: """Return `instance` as a proper future-like object.""" - if isinstance(instance, FutureLike): - return instance - return instance.as_future() + if isinstance(instance, FutureConvertible): + return instance.as_future() + return instance def wait_for_future(