GitHub

worker_runner

API reference for worker_runner.

The worker side of workers (Effect's WorkerRunner).

A WorkerRunner[O, I] runs inside a worker: run(handler) tells the parent the worker is ready, then calls handler(port_id, message) for each I the parent sends, running the effect it returns (if any) on a fiber of its own, until the parent closes the worker. send replies with an O. WorkerRunnerPlatform starts the runner of the current platform; python_worker_runner.layer is the one for Python threads and child processes (Effect's NodeWorkerRunner).

Re-exports

Types

TypeDefinitionDescription
PlatformMessagetype PlatformMessage[I] = tuple[Literal[0], I] | tuple[Literal[1]]

What a parent sends its worker: (0, message), or (1,) to close it.

Handlertype Handler = Callable[[int, Any], Effect[Any, Any, Any] | None]

Classes