Reference
This pages gives the full reference documentation for all modules, classes, and functions in the SnoParallel package.
from snoparallel import Manager, Variable
snoparallel.managers
This module contains the manager class and worker function to control parallelized work cycles.
Manager
Class to control parallelized work cycles.
variables
property
List with the requested Variable instances.
__del__
Terminates the queue and worker processes.
add_references
Add class instances as references for the workers to use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
references
|
list[object]
|
Class instances to add. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
Worker(s) have already been added. |
add_work
Add work items to the queue for the workers to process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
_FunctionType
|
Function to call. |
required |
kwargs
|
Any
|
Keyword arguments to call this function with. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Worker(s) have not yet been added. |
IndexError
|
Index for reference is not provided. |
add_workers
Request workers to process work items from the queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workers
|
int
|
Number of workers to start. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
Worker(s) have already been added. |
request_variable
Request a variable which can be shared between workers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
VariableType
|
Initial value of the variable. |
required |
Returns:
| Type | Description |
|---|---|
Variable
|
Variable instance with the given name and value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
Type of the value not supported. |
wait
Wait for the workers to finish.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
Optional[int | float]
|
Seconds to wait for workers to finish. No time limit when value is None. |
required |
Raises:
| Type | Description |
|---|---|
ChildProcessError
|
Worker(s) failed while processing work. |
TimeoutError
|
Worker(s) did not finish before timeout. |
snoparallel.variables
This module contains the variable class to access variables in parallelized work cycles.
Variable
Class to access variables in parallelized work cycles.
__init__
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
VariableType | ArrayType
|
Initial value to set for the variable. |
required |
memory
|
str
|
Reference to the memory location where the variable value is stored. |
required |
lock
|
Lock
|
SyncManager.Lock instance which is coupled to the variable. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Type of the value not supported. |
read
Read the (old) variable value.
Returns:
| Type | Description |
|---|---|
VariableType | ArrayType
|
Variable value. |
update
Update the old variable value with the new one.
write
Write the new variable value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
VariableType | ArrayType
|
New variable value. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Value type does not correspond with the variable type. |
get_variable_size
Get the variable size in bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
VariableType
|
Variable value. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Variable size in bytes. |