mirror of
https://github.com/codex-storage/bittorrent-benchmarks.git
synced 2025-02-20 23:08:06 +00:00
fix: add retry to download progress queries
This commit is contained in:
parent
750a19e3e0
commit
e8d479da69
@ -206,9 +206,12 @@ class ResilientCallWrapper:
|
|||||||
|
|
||||||
|
|
||||||
class DelugeDownloadHandle(DownloadHandle):
|
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._node = node
|
||||||
self.torrent = torrent
|
self.torrent = torrent
|
||||||
|
self.missing_retries = missing_retries
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def node(self) -> DelugeNode:
|
def node(self) -> DelugeNode:
|
||||||
@ -224,6 +227,18 @@ class DelugeDownloadHandle(DownloadHandle):
|
|||||||
f"Client has multiple torrents matching name {name}. Returning the first one."
|
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]
|
status = list(response.values())[0]
|
||||||
return status[b"is_seed"]
|
return status[b"is_seed"]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user