Repository navigation
feat: torrents download in the background, so MAM grabs aren't capped at the worker count - #68
Merged
Conversation
… at the worker count A worker stayed with each torrent until the client finished downloading it, so only MAX_CONCURRENT_DOWNLOADS torrents (3 by default) were ever in flight, however many MAM unsatisfied slots were free. - Once a hash-keyed torrent client (Deluge, qBittorrent, Transmission, rTorrent) has had a torrent for 30 seconds (or it stalls), its worker is freed. The task stays downloading, with the client's progress (checked every 30 seconds), and goes back to the workers to import when the client has finished it; it fails if the torrent leaves the client. - BookQueue.detach frees the worker and re-saves the retry data (with the hash), so a retry after a restart finds the torrent in the client. - Coming back to import isn't a new MAM snatch: the handoff is recorded once per task in the client, and such tasks don't count as pending snatches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0184DMrDNkAEmGzPntj3ziqB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
With 80/150 unsatisfied slots used, Shelfmark grabbed only 3 MAM torrents at a time, with long waits in between. The slot logic wasn't the limit: about 65 slots were free. The limit was Max Concurrent Downloads (default 3). A worker stayed with each torrent until the client finished downloading it, so only 3 torrents were ever in flight.
What changes
.torrentfetch).BookQueue.detachfrees a downloading task's worker and runs the queue hook, which saves the retry data again with the client hash. So a retry after a restart finds the torrent in the client, even during a MAM freeze.DownloadTask.handoff_recorded;forget_handoffresets it after a refused grab).pending_unsat_countskips tasks that are queued only to import.Testing
tests/download/test_wait_in_client.py, rewritten (18 tests):mainin this container (they run as root).🤖 Generated with Claude Code
https://claude.ai/code/session_0184DMrDNkAEmGzPntj3ziqB
Generated by Claude Code