proxystore.store.future¶
Proxy-future interface implementation.
PollingPolicy
dataclass
¶
PollingPolicy(
interval: float = 1,
backoff_factor: float = 1,
interval_limit: float | None = None,
timeout: float | None = None,
)
Policy for polling a store until an object is available.
Attributes:
-
interval(float) –Initial seconds to sleep between polling the store for the object.
-
backoff_factor(float) –Multiplicative factor applied to the interval after each unsuccessful poll.
-
interval_limit(float | None) –Maximum interval allowed. Prevents the backoff factor from increasing the interval to unreasonable values.
-
timeout(float | None) –Optional maximum number of seconds to poll for.
ProxyFuture
¶
ProxyFuture(factory: PollingStoreFactory[ConnectorT, T])
Bases: Generic[T]
Future interface to a Store.
Tip
Create a ProxyFuture with
Store.future().
Note
If the result of the future is an exception, getting the result or
resolving the proxy of the future raises the exception. Use
set_exception()
to make that clear, but
set_result()
with an exception does the same.
Parameters:
-
factory(PollingStoreFactory[ConnectorT, T]) –Factory that can resolve the object once it is resolved. This factory should block when resolving until the object is available.
Source code in proxystore/store/future.py
proxy
¶
proxy() -> Proxy[T]
Create a proxy which will resolve to the result of this future.
If an exception is set on the future, resolving the proxy raises
a ProxyResolveError caused by
the exception.
Source code in proxystore/store/future.py
result
¶
result(timeout: float | None = None) -> T
Get the result object of this future.
Parameters:
-
timeout(float | None, default:None) –Maximum number of seconds to wait for the result. If
None, the timeout of thePollingPolicyof the future is used.
Raises:
-
TimeoutError–If the result is not available after
timeoutseconds. -
Exception–The result of the future if it is an exception (see
set_exception()).
Source code in proxystore/store/future.py
set_exception
¶
set_exception(exception: BaseException) -> None
Set the exception of this future.
The exception is the result of the future, so it is raised by
result() and when
resolving the proxy of this future. The exception is serialized
with the serializer of the store.
Parameters:
-
exception(BaseException) –Exception to raise.
Source code in proxystore/store/future.py
set_result
¶
Set the result object of this future.
Note
If obj is an exception, it is raised by
result() and
when resolving the proxy of this future.
Parameters:
-
obj(T) –Result object.