refactor(reporters): remove cancel_event from progress reporters

Thread cancel_event explicitly through the parameter chain
(sync_run closure → download_book() → streaming calls) instead of
stashing it on reporter objects as shared state. Remove the
cancel_event attribute from both PlainTextReporter and
ProgressReporter — cancellation is not a reporting concern.

Closes #39

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
AlexKuceraandClaude Opus 4.6 committed 2026-06-05 18:45:27 +02:00
1 parent caca930c7c
commit 2930d163b2
9 files changed
+154 -9

No files matched your search

+2 -1
View File
@@ -239,6 +239,7 @@ def download_book(
reporter: "DownloadReporter",
*,
progress: "Callable[[int], None] | None" = None,
cancel_event: threading.Event | None = None,
rename_chapters: bool = False,
) -> DownloadResult:
"""Orchestrate a single book download with format strategy.
@@ -260,7 +261,7 @@ def download_book(
# Use provided bound callback (from start_download) or fall back to reporter.update
if progress is None:
progress = reporter.update
cancel_event = reporter.cancel_event
# Cooperative cancellation: explicit parameter (Issue #39 — no longer via reporter)
transport = session.transport
# --- m4b_mp3_fallback: try M4B first, fall back to MP3 ---