Skip to main content
Source: src/cwsandbox/_function.py:41
Wrapper for remote function execution in sandboxes. RemoteFunction wraps a Python function for execution in a sandbox. It provides methods to execute remotely, locally (for testing), and map over multiple inputs in parallel. The wrapped function must be synchronous. Async functions are not supported.

Methods

remote

Execute the function in a sandbox, return OperationRef immediately. Parameters
  • *args (P.args): Positional arguments to pass to the function.
  • **kwargs (P.kwargs): Keyword arguments to pass to the function.
Returns
  • OperationRef[R]: OperationRef[R]: Use .result() to block until result is ready.
Examples

map

Execute the function for each item, return OperationRefs immediately. Each item should be a tuple of positional arguments for the function. All executions are launched in parallel. Parameters
  • items (Iterable[tuple[Any, ...]]): Iterable of argument tuples to pass to the function.
Returns
  • list[OperationRef[R]]: List of OperationRef[R], one for each item.
Examples

local

Execute the function locally without a sandbox. Useful for testing and debugging. Runs the original function directly in the current Python process. Parameters
  • *args (P.args): Positional arguments to pass to the function.
  • **kwargs (P.kwargs): Keyword arguments to pass to the function.
Returns
  • R: The result of the function execution.
Examples
Last modified on September 17, 2026