Skip to content

Returns a launcher for mizu_pool() that spawns each worker as a Python process running python -m pymizu.worker, the worker entry of pymizu, the Python binding of the same shared-memory core. The mirror of pymizu's r_pool_launcher(), which spawns R workers from a Python host.

Usage

mizu_py_pool_launcher(python = NULL, stdout = "", stderr = "")

Arguments

python

path to the Python interpreter. The default looks up python3 on the PATH.

stdout, stderr

forwarded to system2() for the peer process, as in mizu_launcher().

Value

A function(token, slot) that spawns one worker process, for the launcher argument of mizu_pool() and mizu_spawn_workers().

Details

The first worker's join records the workers' language in the pool, so the launcher carries no language attribute: a pool of Python workers takes mizu_call() specifications through mizu_submit_call(), and a native mizu_submit() errors locally naming the spec verb. A launcher that spawns the wrong language fails at join, not at the first task.

The interpreter is probed for pymizu when the launcher is created, so a missing interpreter or package raises here, before any pool exists.

Examples

if (FALSE) { # \dontrun{
p <- mizu_pool(2, launcher = mizu_py_pool_launcher())
t <- mizu_submit_call(p, mizu_call("numpy.mean", runif(100)))
mizu_collect(t)
mizu_pool_stop(p)
} # }