From c58184c041e0c5128d93f651f74747ce5ed294d4 Mon Sep 17 00:00:00 2001 From: Piotr Maslanka <piotr.maslanka@ericsson.com> Date: Mon, 4 Mar 2024 12:25:06 +0100 Subject: [PATCH] added DeferredValue.result Change-Id: I85802737669464a529e6f18694db6b6817c5b0ad --- satella/coding/concurrent/value.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/satella/coding/concurrent/value.py b/satella/coding/concurrent/value.py index 2ec6eee9..2bd1de4f 100644 --- a/satella/coding/concurrent/value.py +++ b/satella/coding/concurrent/value.py @@ -43,10 +43,15 @@ class DeferredValue(tp.Generic[T]): self.val = va self.lock.set() + def result(self, timeout=None) -> T: + """An alias for :meth:`~satella.coding.concurrent.DeferredValue.value`""" + return self.value(timeout) + def value(self, timeout: tp.Optional[float] = None) -> T: """ Wait until value is available. + :param timeout: number of seconds to wait. If None is given, this will take as long as necessary. :return: a value :raises WouldWaitMore: timeout was given and it has expired """ -- GitLab