`((torrent.date_done + nold) <= datetime.now() or (nupl > 0 and torrent.ratio >= nupl))` Won't nold be 0 seconds when just uploaded is set (your example 3), making the first half of this true as soon as the torrent is completed, not even checking uploaded?