mirror of
https://github.com/logos-storage/bittorrent-benchmarks.git
synced 2026-01-02 13:03:13 +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):
|
||||
def __init__(
|
||||
self, torrent: Torrent, node: DelugeNode, missing_retries: int = 10
|
||||
) -> None:
|
||||
def __init__(self, torrent: Torrent, node: DelugeNode) -> None:
|
||||
self._node = node
|
||||
self.torrent = torrent
|
||||
self.missing_retries = missing_retries
|
||||
|
||||
@property
|
||||
def node(self) -> DelugeNode:
|
||||
@ -228,16 +225,9 @@ class DelugeDownloadHandle(DownloadHandle):
|
||||
)
|
||||
|
||||
if len(response) == 0:
|
||||
if self.missing_retries == 0:
|
||||
raise ValueError(
|
||||
f"Client {self._node.name} has no torrents matching name {name}."
|
||||
)
|
||||
|
||||
logger.warning(
|
||||
raise ValueError(
|
||||
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"]
|
||||
|
||||
@ -90,6 +90,27 @@ def test_should_return_false_when_file_does_not_exist(
|
||||
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:
|
||||
def __init__(self):
|
||||
self.count = 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user