src/slop_code/execution/local_runtime.py implements a host-based
SubmissionRuntime. It is the fastest option for trusted code paths and mirrors
exactly what would happen if the user executed the command directly on their
machine.
- The session passes a prepared workspace directory, resolved static assets, and
optional setup command overrides when calling
LocalRuntime.spawn(). - Setup commands defined on the
LocalEnvironmentSpecrun immediately before the runtime is handed back to the caller. This keeps behaviour consistent with the Docker backend. - Each runtime instance owns a single
subprocess.Popen. New commands wait for the previous process to exit (or are forced to exit) before reusing the runtime.
LocalRuntime exposes the full SubmissionRuntime interface:
execute()starts a process with optional stdin, waits for completion (respecting the timeout), and returns aRuntimeResultpopulated with stdout/stderr.stream()demultiplexes stdout/stderr usingselectors.DefaultSelectorand yieldsRuntimeEventobjects. Stdin is not supported in streaming mode; adapters should fallback toexecute()if interactive input is required.poll()delegates toPopen.poll()so sessions can check liveness without blocking.kill()andcleanup()terminate lingering processes when sessions exit.
All commands honour environment variables from LocalEnvironmentSpec.get_full_env()
and execute relative to the workspace directory managed by the session.
- If a timeout is provided to
execute(), the process is killed and the result is markedtimed_out=True. SolutionRuntimeErroris raised when callers attempt to access the underlying process before it exists or after it has been cleaned up.- Streams are consumed in text mode (
encoding="utf-8", errors="replace") to avoid crashes on malformed output while keeping behaviour deterministic.
- Rapid iteration during development or CI when container overhead is unnecessary.
- Debugging evaluation failures locally with full insight into the workspace.
- Scenarios where Docker is unavailable but snapshotting and static asset support are still required.
Because this backend runs processes with host privileges, only use it for trusted submissions or within controlled environments.