fabric ·nustd.mp_pool

Own a pool of processes, from inside the tree.

One Provide holds every worker. Launch one, kill one, send a tree to the one you name. No scheduler to run.

See it.

Launch a worker and get its id back. Point a Teleport at that id. The bracket closing kills every worker it opened.

A pool that lives in the program, not beside it.

nustd.mp is the fabric of one process, and its whole lifecycle is the bracket. nustd.mp_pool is the sibling where the pool itself is the fabric, so it owns interactions over its contents.

Launch, kill, and run-on-worker are statements about what the fabric holds. A worker id is a value in the tree, so the tree decides where work lands.

pool.py
python · 12 locpy
import nu
import nustd
work = ... # your Nu tree
# the pool is the fabric: one bracket owns every worker
program = nu.Provide(nustd.mp_pool.WorkerPool, {"name": "pool"},
nu.Let("w", nustd.mp_pool.Launch(),
nustd.mp_pool.Teleport(body=work, worker=nu.AttrRef("w")),
),
)
nu.run(program)

What you can do with it.

A worker count that answers to the program that needs it.

elastic

Size the pool while it runs.

Launch a worker when the queue grows, kill one when it drains. The pool is a value you interact with, not a constant you set at boot.

addressed

Send work to a worker you name.

Launch hands back an id, and the id is an ordinary child in the tree. Route a body to a specific worker, or fan bodies across many.

bounded

Nothing outlives the bracket.

Closing the Provide kills every worker it opened, newest first. No stragglers, no cleanup handler you have to remember to write.

Try Nu.

One command gets you the wheel with every fabric. Then follow the movies tutorial to build a real app in an afternoon.

01 Install

pip install "nustack-py[all]"

02 Run the demo

nu demo movies

03 Build your app

Browse examples

Like what you see?

The project is young. Star it, join the room, watch what we ship next.