mirror of
https://github.com/logos-storage/bittorrent-benchmarks.git
synced 2026-01-04 05:53:12 +00:00
fix: remove pointless retry of removals, add test
This commit is contained in:
parent
e8d479da69
commit
2c4ff52c47
@ -206,12 +206,9 @@ class ResilientCallWrapper:
|
|||||||
|
|
||||||
|
|
||||||
class DelugeDownloadHandle(DownloadHandle):
|
class DelugeDownloadHandle(DownloadHandle):
|
||||||
def __init__(
|
def __init__(self, torrent: Torrent, node: DelugeNode) -> None:
|
||||||
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:
|
||||||
@ -228,16 +225,9 @@ class DelugeDownloadHandle(DownloadHandle):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if len(response) == 0:
|
if len(response) == 0:
|
||||||
if self.missing_retries == 0:
|
raise ValueError(
|
||||||
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}."
|
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"]
|
||||||
|
|||||||
@ -90,6 +90,27 @@ def test_should_return_false_when_file_does_not_exist(
|
|||||||
assert not deluge_node2.remove(torrent)
|
assert not deluge_node2.remove(torrent)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_should_raise_value_error_when_awaiting_on_non_existing_file(
|
||||||
|
deluge_node1: DelugeNode, tracker: Tracker
|
||||||
|
):
|
||||||
|
# XXX This is a bit convoluted, but the easiest way I could find to do this.
|
||||||
|
torrent = deluge_node1.genseed(
|
||||||
|
size=megabytes(1),
|
||||||
|
seed=1234,
|
||||||
|
meta=DelugeMeta(name="dataset1", announce_url=tracker.announce_url),
|
||||||
|
)
|
||||||
|
|
||||||
|
deluge_node1.remove(torrent)
|
||||||
|
|
||||||
|
handle = deluge_node1.leech(torrent)
|
||||||
|
|
||||||
|
deluge_node1.remove(torrent)
|
||||||
|
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
handle.await_for_completion(5)
|
||||||
|
|
||||||
|
|
||||||
class FlakyClient:
|
class FlakyClient:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.count = 0
|
self.count = 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user