Skip to content

PyodideExecutionEnvironmentConfig

Base classes

Name Children Inherits
BaseExecutionEnvironmentConfig
exxec_config.configs
Base execution environment configuration.

â‹” Inheritance diagram

graph TD
  1907353849["configs.PyodideExecutionEnvironmentConfig"]
  2844377061["configs.BaseExecutionEnvironmentConfig"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  2844377061 --> 1907353849
  330168112 --> 2844377061
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseExecutionEnvironmentConfig

Pyodide execution environment configuration.

Executes Python code in WASM via Deno for sandboxed browser-like execution.

Source code in src/exxec_config/configs.py
class PyodideExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Pyodide execution environment configuration.

    Executes Python code in WASM via Deno for sandboxed browser-like execution.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Pyodide Execution Environment"})

    type: Literal["pyodide"] = Field("pyodide", init=False)

    startup_timeout: float = Field(default=60.0, gt=0.0, title="Startup Timeout")
    """Timeout for Pyodide initialization in seconds."""

    allow_net: bool | list[str] = Field(default=True, title="Network Access")
    """Network access (True=all, list=specific hosts, False=none)."""

    allow_read: bool | list[str] = Field(default=False, title="File Read Access")
    """File read access."""

    allow_write: bool | list[str] = Field(default=False, title="File Write Access")
    """File write access."""

    allow_env: bool | list[str] = Field(default=False, title="Environment Variable Access")
    """Environment variable access."""

    allow_run: bool | list[str] = Field(default=False, title="Subprocess Execution")
    """Subprocess execution (limited in WASM)."""

    allow_ffi: bool | list[str] = Field(default=False, title="FFI Access")
    """Foreign function interface access."""

    deno_executable: str | None = Field(
        default=None,
        title="Deno Executable",
        examples=["deno", "/usr/local/bin/deno"],
    )
    """Path to deno executable (auto-detected if None)."""

    sandbox_timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Sandbox Lifetime",
        examples=[300.0, 600.0, 3600.0],
    )
    """How long the sandbox stays alive in seconds."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> PyodideExecutionEnvironment:
        """Create Pyodide execution environment instance."""
        from exxec.pyodide_provider import PyodideExecutionEnvironment

        return PyodideExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            timeout=self.sandbox_timeout,
            default_command_timeout=self.default_command_timeout,
            startup_timeout=self.startup_timeout,
            allow_net=self.allow_net,
            allow_read=self.allow_read,
            allow_write=self.allow_write,
            allow_env=self.allow_env,
            allow_run=self.allow_run,
            allow_ffi=self.allow_ffi,
            deno_executable=self.deno_executable,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

allow_env class-attribute instance-attribute

allow_env: bool | list[str] = Field(default=False, title='Environment Variable Access')

Environment variable access.

allow_ffi class-attribute instance-attribute

allow_ffi: bool | list[str] = Field(default=False, title='FFI Access')

Foreign function interface access.

allow_net class-attribute instance-attribute

allow_net: bool | list[str] = Field(default=True, title='Network Access')

Network access (True=all, list=specific hosts, False=none).

allow_read class-attribute instance-attribute

allow_read: bool | list[str] = Field(default=False, title='File Read Access')

File read access.

allow_run class-attribute instance-attribute

allow_run: bool | list[str] = Field(default=False, title='Subprocess Execution')

Subprocess execution (limited in WASM).

allow_write class-attribute instance-attribute

allow_write: bool | list[str] = Field(default=False, title='File Write Access')

File write access.

deno_executable class-attribute instance-attribute

deno_executable: str | None = Field(
    default=None, title="Deno Executable", examples=["deno", "/usr/local/bin/deno"]
)

Path to deno executable (auto-detected if None).

sandbox_timeout class-attribute instance-attribute

sandbox_timeout: float = Field(
    default=300.0, gt=0.0, title="Sandbox Lifetime", examples=[300.0, 600.0, 3600.0]
)

How long the sandbox stays alive in seconds.

startup_timeout class-attribute instance-attribute

startup_timeout: float = Field(default=60.0, gt=0.0, title='Startup Timeout')

Timeout for Pyodide initialization in seconds.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> PyodideExecutionEnvironment

Create Pyodide execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> PyodideExecutionEnvironment:
    """Create Pyodide execution environment instance."""
    from exxec.pyodide_provider import PyodideExecutionEnvironment

    return PyodideExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        timeout=self.sandbox_timeout,
        default_command_timeout=self.default_command_timeout,
        startup_timeout=self.startup_timeout,
        allow_net=self.allow_net,
        allow_read=self.allow_read,
        allow_write=self.allow_write,
        allow_env=self.allow_env,
        allow_run=self.allow_run,
        allow_ffi=self.allow_ffi,
        deno_executable=self.deno_executable,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

:fa-brands-github: Show source on GitHub