API Reference

Channels

A two-way message link between a Python process and a helper process that it spawns.

Channel

A shared-memory SPSC channel handle (process-private).

Channel Methods

Methods for the Channel class

Channel.create()

Create a channel and spawn its peer.

Channel.attach()

Attach to the channel named by a join token (the peer side).

Channel.token

The join token for the peer’s attach.

Channel.send()

Send one payload.

Channel.send_batch()

Send several payloads in one crossing; return the number

Channel.recv()

Receive one payload.

Channel.recv_async()

The event-driven receive: an asyncio.Future for the next

Channel.__aiter__()

Iterate over received payloads until CLOSED or PEER_GONE —

Channel.recv_batch()

Receive up to n payloads in one crossing; a list

Channel.close()

Orderly close: signal the peer and wait up to timeout

Channel.close_signal()

Signal close without waiting (the peer’s recv side sees

Channel.destroy()

Tear down the handle immediately, without the close

Channel.alive()

True while the peer process is alive.

Channel.info()

A read-only wire-state snapshot of the channel (dict).

Channel.__enter__()
Channel.__exit__()
Channel.__iter__()

Iterate over received payloads until CLOSED or PEER_GONE.

Task pools

A set of worker processes that divide submitted tasks among themselves.

Pool

A shared-memory work-stealing task pool handle (process-private).

Task

A task handle from _Pool.submit(). Collected exactly once; an uncollected handle’s finalizer releases its slot.

PreparedMap

A map staged once into a persistent region, run many times.

PoolExecutor

A concurrent.futures.Executor over a pymizu pool.

Pool Methods

Methods for the Pool class

Pool.create()

Create a pool and spawn its worker processes.

Pool.attach()

Attach to a live pool as a submitter, by its join token.

Pool.token

The join token for worker/submitter attach.

Pool.submit()

Submit fn(*args, **kwargs) as a task; return a Task handle.

Pool.submit_batch()

Submit one task per zero-arg callable in fns in one

Pool.collect_any()

Wait on several tasks.

Pool.collect_all()

Wait until every task is terminal.

Pool.collect_any_async()

The event-driven collect_any():

Pool.collect_all_async()

The event-driven collect_all():

Pool.map()

Map fn over the elements of x on the pool; return the

Pool.starmap()

Map fn over x, unpacking each element as the call’s

Pool.map_prepare()

Stage a map once for repeated runs; return a

Pool.retire()

Ask the worker in slot to exit cleanly (non-blocking,

Pool.spawn_workers()

Spawn n additional workers into free registry slots and

Pool.stop()

Orderly shutdown (controller only).

Pool.shutdown()

Alias for stop() — the

Pool.destroy()

Tear down the pool handle immediately, without the shutdown

Pool.status()

A read-only wire-state snapshot of the pool (dict).

Pool.dump()

A read-only debugging snapshot of the whole pool region (dict).

Pool.stats()

Cumulative per-worker and per-submitter counters since each

Pool.trace()

Register a hook called as fn(event, id) at each task

Pool.__enter__()
Pool.__exit__()

Task Methods

Methods for the Task class

Task.state
Task.pool
Task.collect()

collect(timeout=None) -> value | sentinel

Task.result()

result(timeout=None) -> value | sentinel

Task.cancel()

cancel() -> bool

Task.collect_async()

collect_async() -> asyncio.Future

Task.__await__()

Return an iterator to be used in await expression.

Cross-language interop

R peers and workers (the mizu R package), neutral task specifications, and the data.frame’s Python home.

call

A task specification for a pool of another language’s workers.

r_launcher()

Return a Channel.create() launcher

r_pool_launcher()

Return a Pool.create() launcher

Frame

A data.frame’s Python home: named columns with a row count.

DimArray

An ndarray carrying R labels (names / dimnames /

Frame Methods

Methods for the Frame class

Frame.names
Frame.row_names
Frame.to_dict()

to_dict() -> dict

Frame.from_arrow()

from_arrow(obj) -> Frame

Frame.__arrow_c_stream__()

arrow_c_stream(requested_schema=None) -> capsule

Frame.__len__()

Return len(self).

Frame.__reduce__()

Outcomes and errors

Terminal transport states return as the sentinel singletons FULL / TIMEOUT / CLOSED / PEER_GONE (identity-tested, never raised); real failures raise from the exception hierarchy.

Sentinel

Terminal-state sentinel returned by pymizu verbs. Identity-tested against pymizu.FULL / TIMEOUT / CLOSED / PEER_GONE.

is_sentinel()

is_sentinel(x) -> bool

is_remote_error()

Test whether a received channel value is a remote error.

MizuError

Base class for all pymizu errors.

ShmError

A shared-memory region operation failed. Also an OSError: the failure is at the OS layer.

StartupError

A channel peer or pool worker failed to attach within the startup timeout.

SubmitTimeoutError

Pool.submit() timed out waiting for injection-ring space. Also a TimeoutError.

SlotsExhaustedError

Pool.submit() found no free result slot: too many outstanding (uncollected) tasks.

StoppedError

The pool is stopped; no further submission is possible.

CancelledError

The task was cancelled before it ran.

TaskError

The task callable raised. Carries ‘remote_type’ and ‘remote_traceback’ attributes describing the worker-side exception.

WorkerDiedError

The executing worker died mid-task. Carries ‘slot’ and ‘pid’ attributes identifying the worker.

DeclinedError

A send on a foreign-language channel of a value outside the portable interchange subset. Carries ‘path’ and ‘reason’ attributes.

Housekeeping

The process-wide default pool, the evaluating worker’s own pool handle, and orphan reaping.

default_pool()

The process-wide default pool, or None when none is set.

set_default_pool()

Set the process-wide default pool; None clears it.

using_pool()

Use pool as the default for the with block, then restore.

current_pool()

The evaluating worker’s own pool handle, inside a task.

current_rng()

The running element’s own numpy Generator, inside a seeded map.

prune()

Remove orphaned shared memory regions.