parallel
parallel
#
The one thread pool every pmap runs on, and the parallel broadcast rule.
- Pool. One process-wide pool, sized to the CPU count. A
pmapmade from inside a worker runs sequentially, the outer pool being the parallelism, so nested fan-out never oversubscribes and never waits on the pool it occupies. - Cap.
parallelism(workers)bounds how many elements eachpmapin the block has in flight at once; the default is the pool's size. - Broadcast.
pbroadcastisarray.broadcastacross the pool: the same results, the same failure rule, a progress step counting the elements as they finish, each worker in a copy of the caller's context so the active scratch, workspace and step carry over.
POOL_SIZE = os.cpu_count() or 1
module-attribute
#
How many threads the pool runs, and the default cap on elements in flight.
parallelism(workers)
#
Cap how many elements each pmap in the block has in flight at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workers
|
int
|
The cap; |
required |
Source code in capturegraph-lib/capturegraph/types/containers/parallel.py
pbroadcast(items, operation, function, label)
#
broadcast across the pool: the parallel rule Array and Map share.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
Iterable[I]
|
The elements to apply |
required |
operation
|
str
|
Names this broadcast in the failure message. |
required |
function
|
Callable[[I], R]
|
The per-element operation. |
required |
label
|
str | None
|
What the step counting the elements shows; |
required |
Returns:
| Type | Description |
|---|---|
list[R]
|
What |