Skip to content

A bot we cannot reach is paused, and a full disk makes fetching wait (#926) - #929

Merged
Ninja-FSE merged 3 commits into
mainfrom
feat/926-pause-a-failing-bot
Sep 24, 2026
Merged

Ninja-FSE merged 3 commits into
mainfrom
feat/926-pause-a-failing-bot

Conversation

@chchatzop

Copy link
Copy Markdown
Collaborator

Item 4 of #926. Stacked on #928 (→ #927). Merges cleanly with #925.

  • Pause after 3 failed connections. Three active connect failures in a row (CONNECT_FAILURES_TO_PAUSE) pause a bot. This is AutoGet's "disable after 3 unable to connect".
    • Its requests stay queued and wait as Paused, with a Resume this bot button on the Downloads page. The debug feed says so once.
    • A finished transfer resets the count.
    • A passive offer nobody connects back to doesn't count, since that's our side, not theirs.
  • Operator pause/resume for any bot: POST /api/fetch/pause and /api/fetch/resume, GET /api/fetch/paused.
    • Pauses are saved to fetch_paused_bots.json beside the fetch history, with the path derived from db.FETCH_HISTORY_FILE. That means it follows every existing redirect, the test harness included.
    • A pause survives a restart. The failure count is kept in memory only.
  • A full disk makes fetching wait. With less than 200 MB free in FETCHED_FILES_DIR (MIN_FREE_BYTES):
    • no new fetch starts, and rows wait as Waiting for disk space;
    • an ENOSPC mid-transfer sends the row back to pending instead of failing it;
    • both carry on by themselves once space frees up, and the change is announced once each way;
    • a disk that can't be measured is not called low.

Tests: tests/test_a_failing_bot_is_paused.py (14).

  • Two of them run the real _run_transfer() over a socket.socketpair(): a successful transfer resetting the count, and a write raising ENOSPC sending the row back to pending.
  • Six mutations were checked, and each fails a test.
  • tests/support.py resets the pause state between tests.
  • Full suite 6638 OK. Docs: both changelogs.

What's left in #926 is the list items, 5–8.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AP6LSxkr4n9dMFNSNMogmW

chchatzop and others added 2 commits September 24, 2026 12:05
…926)

- Three active connect failures in a row pause a bot: its requests wait,
  "Paused", with a Resume button. A finished transfer resets the count;
  a passive offer nobody connects back to does not count.
- Any bot can be paused and resumed (POST /api/fetch/pause, /resume);
  pauses are saved beside the fetch history and survive a restart.
- Under 200 MB free where fetched files go, no new fetch starts, and a
  transfer that fills the disk goes back to pending. Both carry on by
  themselves once there is space.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AP6LSxkr4n9dMFNSNMogmW
On Linux and macOS socket.socketpair() is AF_UNIX, whose getpeername()
is '' - _run_transfer() reads [0] of it, which only a TCP address has.
Six CI jobs failed there; Windows' pair is TCP and passed. Real fetches
are always TCP, so the test wraps its end instead of changing the code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AP6LSxkr4n9dMFNSNMogmW
@Ninja-FSE
Ninja-FSE merged commit badcd86 into main Sep 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants