listen_pool
listen_pool(port, allow=(...))
Input: port, allow · Output: no output
What it is
port (integer, 0-65535) is the TCP port to bind. allow=(...) (a list of strings, required and non-empty) names exactly which already-defined functions this listener may run for a remote caller — a hard security requirement, not an option. Binds port and blocks forever (this call never returns under normal operation), accepting job requests over TCP and running only functions named in allow. A request for anything else is rejected cleanly (never a crash, never executed anyway). Each accepted job runs on a fresh, isolated interpreter seeded from a snapshot of the listening script's own globals/functions, taken once when listen_pool is called.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
listen_pool(port, allow=(...)) | port —port (integer, 0-65535) is the TCP port to bind.allow string (default (...))allow=(...) (a list of strings, required and non-empty) names exactly which already-defined functions this listener may run for a remote caller — a hard security requirement, not an option. | no output | A request for anything else is rejected cleanly (never a crash, never executed anyway). Each accepted job runs on a fresh, isolated interpreter seeded from a snapshot of the listening script's own globals/functions, taken once when listen_pool is called. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
square(x) := x * x
listen_pool(9000, allow=("square")) # blocks forever, serving requests
from tour
square(x) := x * x
function run_listener()
listen_pool(9321, allow=("square"))
end function
w = spawn("run_listener") # the "remote" side, on its own thread here
sleep(0.3) # give it time to bind before connecting
pool workers with cpu=1, remote=("127.0.0.1:9321")
end pool
q = queue()
for i in 0 to 4
q.push("square", i)
end for
results = run q on workers # some local, some "remote" — one ordered List
print(results) # (0, 1, 4, 9, 16)
from concurrency
How it works
listen_pool(port, allow=("fnA", "fnB", ...)) (§ distributed job dispatch, 2026-08-31) — the remote-worker half of pool ... with cpu=N, remote=("host:port", ...): blocks forever, accepting job requests over TCP and running only functions named in allow (a hard security requirement — never an arbitrary requested name; see remote_pool's own doc comment for the wire protocol, the allowlist check, and the isolation model). allow is required and must be non-empty — an empty allowlist could never run anything.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.