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:
1 parent
caca930c7c
commit
2930d163b2
9 files changed
+154
-9
No files matched your search
@@ -191,13 +191,14 @@ def sync_run(
|
||||
# 6. Download loop with TTY-aware reporting
|
||||
reporter = DownloadReporter()
|
||||
cancel_event = threading.Event()
|
||||
reporter.cancel_event = cancel_event
|
||||
# cancel_event passed explicitly via closure to download_book() (Issue #39)
|
||||
console.print(f"\n[bold]{len(new_books)} book(s) to download:[/bold]\n")
|
||||
|
||||
# --- Download loop (parallel via orchestrator — Issue #16) ---
|
||||
|
||||
def _make_download_fn():
|
||||
_rc = resolved_rename_chapters # capture resolved value
|
||||
_ce = cancel_event # capture for closure (Issue #39 — explicit param, not via reporter)
|
||||
|
||||
def _download_fn(
|
||||
book: Book, *, progress: Callable[[int], None] | None = None
|
||||
@@ -209,7 +210,7 @@ def sync_run(
|
||||
config=config,
|
||||
format_strategy=config.format,
|
||||
)
|
||||
result = download_book(book, client, plan, reporter, progress=progress, rename_chapters=_rc)
|
||||
result = download_book(book, client, plan, reporter, progress=progress, rename_chapters=_rc, cancel_event=_ce)
|
||||
|
||||
# Write history as caller (no longer inside download_book)
|
||||
if result.status == "downloaded":
|
||||
|
||||
Reference in new issue
Block a user