libmuscle.util module

class libmuscle.util.Retrier(timeout: float = 30.0, base_delay: float = 0.5)[source]

Bases: object

Helper class for retrying things with a delay and timeout.

This backs off exponentially, immediately retrying on the first attempt, then waiting 2**tries * base_delay seconds between tries.

should_give_up() bool[source]

Return whether to give up or retry.

sleep() None[source]

Sleep until it’s time for the next retry.

libmuscle.util.extract_log_file_location(filename: str) Path | None[source]

Gets the log file location from the command line.

Extracts the –muscle-log-file=<path> argument to tell the MUSCLE library where to write the local log file. This function will extract this argument from the command line arguments if it is present. If the given path is to a directory, <filename> will be written inside of that directory, if the path is not an existing directory, then it will be used as the name of the log file to write to. If no command line argument is given, this function returns None.

Parameters:

filename – Default file name to use.

Returns:

Path to the log file to write.

libmuscle.util.generate_indices(dims: list[int]) Generator[list[int], None, None][source]

Generates all indices in a block of the given dimensions.

Parameters:

dims – The dimensions of the block.

Yields:

lists of indices, one for each point in the block.

libmuscle.util.instance_indices(instance: Reference) list[int][source]

Extracts the indices from an instance name.

Parameters:

instance – The name of a kernel instance.

Returns:

The name of its kernel.

libmuscle.util.instance_to_kernel(instance: Reference) Reference[source]

Extracts the name of the kernel from an instance name.

Parameters:

instance – The name of a kernel instance.

Returns:

The name of its kernel.