Skip to content

proxystore.store.future

Proxy-future interface implementation.

Future

Future(
    factory: PollingStoreFactory[ConnectorT, T],
    *,
    serializer: SerializerT | None = None
)

Bases: Generic[T]

Future interface to a Store.

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.

  • serializer (SerializerT | None, default: None ) –

    Use a custom serializer when setting the result object of this future.

Source code in proxystore/store/future.py
def __init__(
    self,
    factory: PollingStoreFactory[ConnectorT, T],
    *,
    serializer: SerializerT | None = None,
) -> None:
    self._factory = factory
    self._serializer = serializer

done

done() -> bool

Check if the result has been set yet.

Source code in proxystore/store/future.py
def done(self) -> bool:
    """Check if the result has been set yet."""
    return self._factory.get_store().exists(self._factory.key)

proxy

proxy() -> Proxy[T]

Create a proxy which will resolve to the result of this future.

Source code in proxystore/store/future.py
def proxy(self) -> Proxy[T]:
    """Create a proxy which will resolve to the result of this future."""
    return Proxy(self._factory)

result

result() -> T

Get the result object of this future.

Source code in proxystore/store/future.py
def result(self) -> T:
    """Get the result object of this future."""
    return self._factory.resolve()

set_result

set_result(obj: T) -> None

Set the result object of this future.

Parameters:

  • obj (T) –

    Result object.

Source code in proxystore/store/future.py
def set_result(self, obj: T) -> None:
    """Set the result object of this future.

    Args:
        obj: Result object.
    """
    self._factory.get_store()._set(
        self._factory.key,
        obj,
        serializer=self._serializer,
    )