Stalled torrents using up queue slots

Other platforms, generic questions.
Post Reply
tuaris
Newbie
Newbie
Posts: 2
Joined: Mon Aug 31, 2020 11:01 am

Stalled torrents using up queue slots

Post by tuaris »

I have queuing setup to have a max of 5 downloads and 10 active torrents.
How do I setup queuing so that a stalled torrent doesn't count towards those limits?
User avatar
Peter
Administrator
Administrator
Posts: 2420
Joined: Wed Jul 07, 2010 6:14 pm

Re: Stalled torrents using up queue slots

Post by Peter »

Settings -> Bittorrent -> "Do not count slow torrents in these limits" and then set that up so it fits your needs.
tuaris
Newbie
Newbie
Posts: 2
Joined: Mon Aug 31, 2020 11:01 am

Re: Stalled torrents using up queue slots

Post by tuaris »

Thanks. I am aware of that setting but it's either unclear, doesn't work properly, or I'm not understanding it. For example I have "max of 5 downloads and a max of 10 active torrents", and have the "Do not count slow torrents in these limits" box checked.

The stalled torrents use up the max active slots.

Image

If I bump up the max active torrents to 40, that opens up more download slots, but again, stalled torrents count towards that:

Image
SideshowBob
Newbie
Newbie
Posts: 17
Joined: Wed Jan 15, 2020 11:34 pm

Re: Stalled torrents using up queue slots

Post by SideshowBob »

I just set it large - about 50.

IIRC years ago slow torrents didn't count towards the maximum (although I might possibly be remembering a different client). I'm guessing it changed to avoid the case where all torrents are active and resources are spread too thinly for anything to be above threshold. I've seen that happen on Azureus and it required manual intervention.

Your values of 5,2,10 don't make much sense either way. In one case you are allowing for only 3 slow torrents, and in the other 10 is greater than 5+2. The point of the old behavior was that you could set something like 5,5,7. When the total active torrents exceeded the limit, seeds would be shut down to allow more upload bandwidth for downloads.
benba
Newbie
Newbie
Posts: 1
Joined: Sun Sep 19, 2021 7:36 pm

Re: Stalled torrents using up queue slots

Post by benba »

tuaris wrote: Sun Jan 03, 2021 10:25 am If I bump up the max active torrents to 40, that opens up more download slots, but again, stalled torrents count towards that:
that's the right behaviour...
active_limit is a hard limit on the number of active (auto managed) torrents. This limit also applies to slow torrents.
source: https://www.libtorrent.org/reference-Se ... tings-pack
queuereduce
Newbie
Newbie
Posts: 1
Joined: Mon Jan 16, 2023 4:12 am

Re: Stalled torrents using up queue slots

Post by queuereduce »

Hello,

I am resurrecting this old thread because I was not able to find the an answer to this question anywhere online and this is the first thread that comes up when searching this problem. Hopefully this helps someone else, this is a throw away account FYI so unlikely I respond to requests for further assistance or questions about this solution. Works for me but not planning to support it.

The reason that I was attempting to do this is that my download machine has limited disk space, an enormous down pipe and a very small up pipe. This system moves files after downloads are complete to a different location for longer term storage and seeding. Because of this I want to queue up 1 torrent at a time, download the contents and then move on down the line. So if 1 torrent is stalled the previous setup required manual intervention by me to return to orderly 1 by 1 processing. This is because the stalled torrent will fill my 1 allowed queue slot forever. Personally I believe this is a libtorrent bug and that the "do not count slow torrents towards these limits" setting should behave as seems logical and exclude stalled torrents from the "active" count.

I solved this by using bash scripting and the qbittorrent webUI API.

Prerequisites
-this is running on ubuntu linux 20 (I am sure you could get it working on windows but that is beyond the scope of my response)
-you will need to parse json so you will need to install jq (sudo apt-get install jq). I am sure there are other ways to do this but I believe this is the most simple.
-you will need to schedule a bash script to run on a recurring basis (I have mine running every 1 minute)

The bash script and line by line explanation.

Code: Select all

#replace the values in [] including removing the [] with values that match your instance this line below authenticates with your instance of qbittorrent and may not be needed if you are ignoring auth for local or not using auth

cookie=$(curl -c - --header 'Referer: http://[qbittorrenthost]:[qbittorrentport]' --data 'username=[qbittorrentuser]&password=[qbittorrentpassword]' http://[qbittorrenthost]:[qbittorrentport]/api/v2/auth/login)

#get a list of torrents that are currently stalled and not complete
stallJSON=$(echo "${cookie}" | curl -b - http://[qbittorrenthost]:[qbittorrentport/api/v2/torrents/info?filter=stalled_downloading)

#extract from that list using jq (package must be installed https://stedolan.github.io/jq/) this line looks for torrents where there are 0 seeds and the torrent has been active for at least 1 hour cumulatively. This is designed to give torrents time to get out of a stall and connect to seeds if they exist
hashdropqueue=$(echo "$stallJSON" | jq -r '.[] | select(.num_seeds == 0) | select(.time_active > 3600) | {hash} | join(",")')

#replace spaces between hashes with | for qbittorrent api syntax not sure why join(",") puts spaces between hashes on multiple results but it does and changing to join("|") does not help so this line is necessary for this script to work in the case that multiple torrents are stalled. For me this should not happen since I have my active torrent slots set to 1 but your config may be different 
hashdropqueue=$(echo $hashdropqueue | sed 's/ /|/g')

#move down the queue 1 spot all torrents in list that match the above criteria
echo "${cookie}" | curl -b - -X POST http://[qbittorrenthost]:[qbittorrentport]/api/v2/torrents/decreasePrio -d "hashes=$hashdropqueue"

#This line may not be necessary at all (have not tested if changing prio via the api disables auto management) for my setup I want this on you may want to comment out or delete the below line depending on your setup
echo "${cookie}" | curl -b - -X POST http://[qbittorrenthost]:[qbittorrentport]/api/v2/torrents/setAutoManagement -d 'hashes=$hashdropqueue&enable=true' 

Post Reply