How to use the pottery.exceptions.QuorumNotAchieved function in pottery

To help you get started, we’ve selected a few pottery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brainix / pottery / pottery / nextid.py View on Github external
def _current_id(self, value):
        futures, num_masters_set = set(), 0
        with concurrent.futures.ThreadPoolExecutor() as executor:
            for master in self.masters:
                future = executor.submit(
                    self._set_id_script,
                    keys=(self.key,),
                    args=(value,),
                    client=master,
                )
                futures.add(future)
            for future in concurrent.futures.as_completed(futures):
                with contextlib.suppress(TimeoutError, ConnectionError):
                    num_masters_set += future.result() == value
        if num_masters_set < len(self.masters) // 2 + 1:
            raise QuorumNotAchieved(self.masters, self.key)
github brainix / pottery / pottery / nextid.py View on Github external
def __next__(self):
        for _ in range(self.num_tries):
            with contextlib.suppress(QuorumNotAchieved):
                next_id = self._current_id + 1
                self._current_id = next_id
                return next_id
        else:
            raise QuorumNotAchieved(self.masters, self.key)
github brainix / pottery / pottery / nextid.py View on Github external
def __next__(self):
        for _ in range(self.num_tries):
            with contextlib.suppress(QuorumNotAchieved):
                next_id = self._current_id + 1
                self._current_id = next_id
                return next_id
        else:
            raise QuorumNotAchieved(self.masters, self.key)