Skip to content

Add a ProxyStore concurrent.futures.Executor wrapper #563

@gpauloski

Description

@gpauloski

Describe the Request

Using ProxyStore with a concurrent.futures.Executor compatible interface is pretty common. We could provide our own wrapper with auto-proxying support based on a threshold or filter mechanism.

In the below example, the user provides a should_proxy function. We could provide a set of these with the following functionality:

  • Always proxy
  • Proxy based on sys.getsizeof() threshold (faster, but not always accurate)
  • Proxy based on serialized size (accurate, but might result in double-serialization)
  • Proxy if type is in user-provided list of types

Sample Code

class ProxyExecutor(concurrent.futures.Executor):
    def __init__(
        executor: concurrent.futures.Executor,
        store: Store[Any],
        should_proxy: Callable[[Any], bool],
    ) -> None:
        self.executor = executor
        self.store = store
        ...

    def submit(...) -> ...:
        # Proxy args/kwargs based on should_proxy check.
        # Wrap function in a decorator that will proxy result
        # based on should_proxy check.
        fut = self.executor.submit(...)
        return fut

Metadata

Metadata

Assignees

Labels

enhancementNew features or improvements to existing functionality

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions