Progress + cancellation
Opt-in transfer instrumentation. Pass progress_name="<label>" to
download_file(), s3_upload_file(), or
s3_download_file() and the transfer registers with the shared
progress_registry. From there the GUI
or a JSON action can poll the reporter snapshot or cancel the transfer
mid-flight.
Transfer progress + cancellation primitives.
Long-running transfers (HTTP downloads, S3 uploads/downloads, …) accept a
named handle from the shared progress_registry. The registry keeps a
ProgressReporter (bytes transferred, optional total) and a
CancellationToken per name so the GUI or a JSON action can observe
progress or cancel mid-flight.
Instrumentation is opt-in: callers pass progress_name="<label>" to enable
tracking. When omitted, transfers run exactly as before with zero overhead
beyond one attribute lookup.
- class automation_file.core.progress.CancellationToken[source]
Bases:
objectThread-safe boolean flag, pollable from worker threads.
- exception automation_file.core.progress.CancelledException[source]
Bases:
FileAutomationExceptionRaised when a cancellable operation is asked to stop mid-flight.
- class automation_file.core.progress.ProgressRegistry[source]
Bases:
objectNamed handles so JSON actions / the GUI can address ongoing transfers.
- lookup(name)[source]
- Parameters:
name (str)
- Return type:
tuple[ProgressReporter, CancellationToken] | None
- class automation_file.core.progress.ProgressReporter(name, total=None, transferred=0, status='running', started_at=<factory>, finished_at=None, _lock=<factory>)[source]
Bases:
objectTracks bytes transferred for one named operation.
- Parameters:
- automation_file.core.progress.progress_cancel(name)[source]
Cancel the named transfer. Returns
Falseif no such handle.
- automation_file.core.progress.progress_clear()[source]
Drop every finished transfer from the registry.
- Return type: