yggdrasil.concurrent.pool¶
pool ¶
Bounded thread-pool for large / infinite job streams.
JobPoolExecutor ¶
JobPoolExecutor(
max_workers: int | None = None,
max_in_flight: int | None = None,
job_name_prefix: str = "",
)
Bases: ThreadPoolExecutor
ThreadPoolExecutor helper for large / infinite :class:Job streams.
Keeps at most max_in_flight futures submitted at any time so the caller is never overwhelmed when the job source is unbounded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_workers
|
int | None
|
Thread-pool size ( |
None
|
max_in_flight
|
int | None
|
Max in-flight futures ( |
None
|
job_name_prefix
|
str
|
Thread-name prefix forwarded to |
''
|
Yields (via :meth:as_completed):
:class:JobResult in completion order (ordered=False) or
submission order (ordered=True).
submit_job ¶
Submit a single :class:Job and return its :class:Future.
as_completed ¶
as_completed(
jobs: Iterable[Job],
*,
ordered: bool = False,
max_in_flight: int | None = None,
cancel_on_exit: bool = False,
shutdown_on_exit: bool = False,
shutdown_wait: bool = False,
raise_error: bool = True
) -> Iterator[JobResult]
Consume a (possibly infinite) :class:Job iterable and yield :class:JobResult objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobs
|
Iterable[Job]
|
Source of :class: |
required |
ordered
|
bool
|
|
False
|
max_in_flight
|
int | None
|
Override the instance-level window for this call. |
None
|
cancel_on_exit
|
bool
|
Cancel pending futures on generator close / error. |
False
|
shutdown_on_exit
|
bool
|
Shut down the pool on generator close / error. |
False
|
shutdown_wait
|
bool
|
Wait for running threads when shutting down. |
False
|
raise_error
|
bool
|
Re-raise job exceptions at the yield site. |
True
|
Yields:
| Type | Description |
|---|---|
JobResult
|
class: |