fix: add retry to download progress queries

This commit is contained in:
gmega 2025-01-28 08:30:11 -03:00
parent 750a19e3e0
commit e8d479da69
No known key found for this signature in database
GPG Key ID: 6290D34EAD824B18

View File

@ -206,9 +206,12 @@ class ResilientCallWrapper:
class DelugeDownloadHandle(DownloadHandle):
def __init__(self, torrent: Torrent, node: DelugeNode) -> None:
def __init__(
self, torrent: Torrent, node: DelugeNode, missing_retries: int = 10
) -> None:
self._node = node
self.torrent = torrent
self.missing_retries = missing_retries
@property
def node(self) -> DelugeNode:
@ -224,6 +227,18 @@ class DelugeDownloadHandle(DownloadHandle):
f"Client has multiple torrents matching name {name}. Returning the first one."
)
if len(response) == 0:
if self.missing_retries == 0:
raise ValueError(
f"Client {self._node.name} has no torrents matching name {name}."
)
logger.warning(
f"Client {self._node.name} has no torrents matching name {name}."
)
self.missing_retries -= 1
return False
status = list(response.values())[0]
return status[b"is_seed"]