decluttarr icon indicating copy to clipboard operation
decluttarr copied to clipboard

[NEEDS CODE REVIEWER] (time-out related) Fix detect_deletions disable gating and harden timeout handling

Open tomerh2001 opened this issue 9 months ago • 3 comments

Summary

  • Fix detect_deletions gating so disabled jobs do not start folder watchers (main.py now checks .enabled).
  • Add JobParams.__bool__ so object truthiness consistently reflects job enabled state.
  • Add configurable global HTTP timeout via general.request_timeout (and env REQUEST_TIMEOUT) instead of a hardcoded 15s timeout in make_request.
  • Add runtime error boundaries so request failures in ARR/download-client job groups are logged and the main loop keeps running instead of crashing.
  • Update docs/example config for request_timeout and add regression tests.

Why

  • Fixes behavior reported in #329 (detect_deletions runs even when disabled).
  • Addresses crash-loop behavior from timeout failures in #317 by making timeout tunable and by preventing one request failure from terminating the full run loop.

Validation

  • python3 -m pytest -q
  • python3 -m pylint main.py src/job_manager.py src/utils/common.py src/settings/_general.py src/settings/_jobs.py src/settings/_user_config.py tests/jobs/test_job_manager.py tests/settings/test_general.py tests/settings/test_jobs.py tests/utils/test_common.py

tomerh2001 avatar Feb 28 '26 19:02 tomerh2001

Can we please get this merged? Would like to use V2 but this timeout issue is preventing me from connecting to my qbittorrent instance

AverageCakeSlice avatar Mar 26 '26 14:03 AverageCakeSlice

hi @tomerh2001 , I am truly sorry I haven't looked into your PR in such a long time. I do appreciate very much that you took the time to contribute.

Unfortunately, I don't have the time to look into it still. To overcome me being the bottleneck, I am looking to open this repo up to other people who help maintain it, and contributors can review each others code / merge.

Would you be willing to act as a formal contributor? If yes, I will add you, and if I find others (from open PRs), hopefully you can review each others PR and they can be merged.

Thanks for letting me know, and apologies again for my radio silence. Would love to have you on board!

ManiMatter avatar Apr 18 '26 11:04 ManiMatter

Hey @tomerh2001, thank you for contributing! I am currently reviewing this as part of clearing the open PR backlog with @ManiMatter. Read through against the linked issues — code looks solid, two small asks before I'd approve.

Linkage confirmed:

  • ✅ #329 — main.py now checks .enabled, matches the root cause from the issue exactly. JobParams.__bool__ is a nice belt-and-suspenders touch and the regression test covers it.
  • ✅ #317 — both halves addressed: configurable general.request_timeout (env REQUEST_TIMEOUT), and _run_arr_job_group / _run_download_client_job swallow request errors so one timeout no longer takes down the loop. test_run_jobs_keeps_running_when_one_group_raises_request_error directly exercises the crash scenario.

Ask 1 — auto-close keywords: Could you update the PR body so the issues close on merge? Right now it says "Fixes behavior reported in #329" and "Addresses crash-loop behavior from timeout failures in #317" — GitHub doesn't parse those phrasings (text between keyword and hash), so issues stay open after merge. Two lines would do it:

Closes #329
Fixes #317

Heads-up — overlap with #346: #346 also introduces general.request_timeout (same name, same default) and adds per-instance timeout overrides for arr + qbit + sabnzbd, but doesn't fix the crash behavior or the detect_deletions gate. They'll conflict on the general setting. My take: this PR is the more important merge (closes two high-prio bugs), and #346 can rebase on top to add per-instance granularity. Flagging so we can coordinate merge order.

Code-wise: error boundaries are scoped tightly (per ARR group, per download-client job, per qbit cookie refresh), request_timeout defaults to 15 so existing users see no behavior change, and the new tests are focused. Nothing else from me.

lolimmlost avatar Apr 30 '26 02:04 lolimmlost