Pool.submit()
Submit fn(*args, **kwargs) as a task; return a Task handle.
Usage
Pool.submit(
fn,
/,
*args,
timeout=None,
**kwargs,
)Blocks only for injection-ring space, up to timeout seconds (None waits indefinitely).
Parameters
fn: _Callable[…, _Any]-
The callable to run, or a
callspec. args: _Any = ()-
Positional arguments for
fn. timeout: float | None = None-
Seconds to wait for injection-ring space; None waits indefinitely.
kwargs: _Any = {}-
Keyword arguments for
fn.
Returns
ATaskhandle.
Raises
SubmitTimeoutError-
On
timeoutexpiry. SlotsExhaustedError-
When no result slot is free.
StoppedError- When the pool is stopped.
Details
timeout belongs to the submission, not to fn: a callable taking its own timeout= keyword argument cannot receive it through **kwargs here — bind it first with functools.partial as functools.partial(fn, timeout=...).
A buffer-protocol argument (e.g. a numpy array) past the zero-copy floor crosses as a read-only view over shared pages, not a writable copy.
With a call spec as fn (no *args / **kwargs — the spec carries them), the task stream crosses in the neutral interchange format: this is how a pool of another language’s workers is driven (spawn them with r_pool_launcher()). On a foreign pool a plain callable errors locally, naming the spec verb.
Examples
See Pool.create() for a submit and collect example.