duplicity.backend_pool module

class duplicity.backend_pool.BackendPool(url_string, processes=None)[source]

Bases: object

uses concurrent.futures.ProcessPoolExecutor to run backend commands in background

class CmdStatus(function_name: str, args: Dict, kwargs: List, trk_rcd: duplicity.backend_pool.TrackRecord | None = None, done: bool = False)[source]

Bases: object

__init__(function_name: str, args: Dict, kwargs: List, trk_rcd: TrackRecord | None = None, done: bool = False) None
args: Dict
done: bool = False
function_name: str
kwargs: List
trk_rcd: TrackRecord | None = None
__init__(url_string, processes=None) None[source]
_collect_finished_cmds()[source]

store finished results in all_results and remove command from queue

static _process_init(url_string, config_dump)[source]
_raise_exception_if_any(track_rcrd)[source]

raise the exception stored in track_rcrd if it occurred while running the command

command(func_name, args=(), kwds=None)[source]

run function in a pool of independent processes. Call function by name. func_name: name of the backend method to execute args: positional arguments for the method kwds: key/value arguments for the method

Returns a unique ID for each command, increasing int

command_throttled(func_name, commands_in_buffer=1, args=(), kwds=None)[source]

block, if queue gets bigger then number of workers + commands_in_buffer. Means this function my block a while to process queue and returns if enough queue items has been processed. func_name: name of the backend method to execute commands_in_buffer = number of commands that are queue for execution args: positional arguments for the method kwds: key/value arguments for the method

Returns a unique ID for each command, increasing int

get_queue_length() int[source]
get_stats(last_index=None)[source]
results_since_last_call(from_pos=None) Iterator[TrackRecord][source]

collect results from commands finished since last run of this method. This method should be called from one receiver only, as it keep track of what was send internally. param:

from_pos: use to overwrite the internal pointer __last_results_reported

return:

list of future results

shutdown(*args)[source]
class duplicity.backend_pool.TrackRecord(track_id: int, pid: int, trace_back: Optional[List[str]] = <factory>, result: object = None, log_prefix: str = '', start_time: datetime.datetime = datetime.datetime(2025, 10, 30, 11, 12, 6, 960937), stop_time: datetime.datetime = datetime.datetime(1, 1, 1, 0, 0))[source]

Bases: object

__init__(track_id: int, pid: int, trace_back: ~typing.List[str] | None = <factory>, result: object = None, log_prefix: str = '', start_time: ~datetime.datetime = datetime.datetime(2025, 10, 30, 11, 12, 6, 960937), stop_time: ~datetime.datetime = datetime.datetime(1, 1, 1, 0, 0)) None
get_runtime() timedelta[source]
log_prefix: str = ''
pid: int
result: object = None
start_time: datetime = datetime.datetime(2025, 10, 30, 11, 12, 6, 960937)
stop_time: datetime = datetime.datetime(1, 1, 1, 0, 0)
trace_back: List[str] | None
track_id: int
duplicity.backend_pool.track_cmd(track_id, cmd_name: str, *args, **kwargs)[source]

wraps the pooled function for time tracking and exception handling. Recording the trace back of an exception when still in process pool context to point to the right place. (This function can’t be part of the BackendPool, as then the whole class get pickled)