refactor: centralize progress reporters, default user-agent, improve error propagation and aria2 fetch usage
This commit is contained in:
@@ -41,3 +41,24 @@ def report_progress(
|
||||
progress_callback(payload)
|
||||
except Exception as e:
|
||||
log.debug(f"{error_context} failed: {e}")
|
||||
|
||||
|
||||
def get_progress_reporter(error_context: str) -> Callable[[Optional[Callable[[Dict[str, Any]], None]], str, str, Optional[float]], None]:
|
||||
"""Return a closure for reporting progress with a pre-configured error context."""
|
||||
def reporter(
|
||||
progress_callback: Optional[Callable[[Dict[str, Any]], None]],
|
||||
stage: str,
|
||||
message: str,
|
||||
percent: Optional[float] = None,
|
||||
**extra: Any,
|
||||
) -> None:
|
||||
report_progress(
|
||||
progress_callback,
|
||||
stage,
|
||||
message,
|
||||
percent,
|
||||
error_context=error_context,
|
||||
**extra,
|
||||
)
|
||||
return reporter
|
||||
|
||||
|
||||
Reference in New Issue
Block a user