Raise exception for sampling when there aren't enough nodes to sample.

pull/3294/head
derekpierre 2023-11-07 14:16:13 -05:00 committed by David Núñez
parent 76b9d4af28
commit 4100754976
1 changed files with 4 additions and 0 deletions

View File

@ -114,6 +114,10 @@ class Policy:
self.publisher.block_until_number_of_known_nodes_is(self.shares, learn_on_this_thread=True, eager=True)
reservoir = self._make_reservoir(handpicked_addresses)
if len(reservoir) < self.shares:
raise self.NotEnoughUrsulas(
f"There aren't enough nodes, {len(reservoir)} to sample {self.shares}"
)
value_factory = PrefetchStrategy(reservoir, self.shares)
def worker(address) -> "characters.lawful.Ursula":