How to use the aiozk.exc.ZKError function in aiozk

To help you get started, we’ve selected a few aiozk 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 micro-fan / aiozk / aiozk / recipes / base_lock.py View on Github external
state_fut, states.States.LOST)
                fut.cancel()

            await self.delete_unique_znode(znode_label)

        class Lock:
            async def __aenter__(self):
                return self

            async def __aexit__(self, exc_type, exc, tb):
                await on_exit()

        return Lock()


class LockLostError(exc.ZKError):
    pass
github micro-fan / aiozk / aiozk / recipes / base_watcher.py View on Github external
async def watch_loop(self, path):
        while self.callbacks[path]:
            log.debug("Fetching data for %s", path)
            try:
                result = await self.fetch(path)
            except exc.NoNode:
                result = exc.NoNode
            except exc.ZKError as e:
                log.exception('Exception in watch loop: {}'.format(e))
                log.info('Waiting for safe state...')
                await self.client.session.ensure_safe_state()
                continue
            except Exception:
                log.exception('Not handled in watch loop:')
                raise

            for callback in self.callbacks[path].copy():
                maybe_future(callback(result), loop=self.client.loop)
            if WatchEvent.CREATED not in self.watched_events and result == exc.NoNode:
                return
            try:
                await self.client.wait_for_events(self.watched_events, path)
            except asyncio.CancelledError:
                pass
github micro-fan / aiozk / aiozk / exc.py View on Github external
class ConnectError(ZKError):
    def __init__(self, host, port, server_id=None):
        self.host = host
        self.port = port
        self.server_id = server_id

    def __str__(self):
        return "Error connecting to %s:%s" % (self.host, self.port)


class NoServersError(ZKError):
    pass


class SessionLost(ZKError):
    pass


class InvalidClientState(ZKError):
    pass


class TimeoutError(ZKError):
    pass


class UnfinishedRead(ZKError):
    pass


class FailedRetry(ZKError):
github micro-fan / aiozk / aiozk / exc.py View on Github external
return "Error connecting to %s:%s" % (self.host, self.port)


class NoServersError(ZKError):
    pass


class SessionLost(ZKError):
    pass


class InvalidClientState(ZKError):
    pass


class TimeoutError(ZKError):
    pass


class UnfinishedRead(ZKError):
    pass


class FailedRetry(ZKError):
    pass


class InvalidStateTransition(ZKError):
    pass


response_error_xref = {}
github micro-fan / aiozk / aiozk / exc.py View on Github external
self.port = port
        self.server_id = server_id

    def __str__(self):
        return "Error connecting to %s:%s" % (self.host, self.port)


class NoServersError(ZKError):
    pass


class SessionLost(ZKError):
    pass


class InvalidClientState(ZKError):
    pass


class TimeoutError(ZKError):
    pass


class UnfinishedRead(ZKError):
    pass


class FailedRetry(ZKError):
    pass


class InvalidStateTransition(ZKError):
github micro-fan / aiozk / aiozk / exc.py View on Github external
class ZKError(Exception):
    pass


class ConnectError(ZKError):
    def __init__(self, host, port, server_id=None):
        self.host = host
        self.port = port
        self.server_id = server_id

    def __str__(self):
        return "Error connecting to %s:%s" % (self.host, self.port)


class NoServersError(ZKError):
    pass


class SessionLost(ZKError):
    pass


class InvalidClientState(ZKError):
    pass


class TimeoutError(ZKError):
    pass


class UnfinishedRead(ZKError):
github micro-fan / aiozk / aiozk / exc.py View on Github external
pass


class TimeoutError(ZKError):
    pass


class UnfinishedRead(ZKError):
    pass


class FailedRetry(ZKError):
    pass


class InvalidStateTransition(ZKError):
    pass


response_error_xref = {}


class ResponseErrorMeta(type):

    def __new__(cls, name, bases, attrs):
        new_class = super(ResponseErrorMeta, cls).__new__(
            cls, name, bases, attrs
        )

        response_error_xref[new_class.error_code] = new_class

        return new_class
github micro-fan / aiozk / aiozk / exc.py View on Github external
pass


class SessionLost(ZKError):
    pass


class InvalidClientState(ZKError):
    pass


class TimeoutError(ZKError):
    pass


class UnfinishedRead(ZKError):
    pass


class FailedRetry(ZKError):
    pass


class InvalidStateTransition(ZKError):
    pass


response_error_xref = {}


class ResponseErrorMeta(type):
github micro-fan / aiozk / aiozk / exc.py View on Github external
response_error_xref = {}


class ResponseErrorMeta(type):

    def __new__(cls, name, bases, attrs):
        new_class = super(ResponseErrorMeta, cls).__new__(
            cls, name, bases, attrs
        )

        response_error_xref[new_class.error_code] = new_class

        return new_class


class ResponseError(ZKError, metaclass=ResponseErrorMeta):
    error_code = None

    def __str__(self):
        return self.__class__.__name__


class UnknownError(ResponseError):

    def __init__(self, error_code):
        print(repr(error_code))
        self.error_code = error_code

    def __str__(self):
        return "Unknown error code: %s" % self.error_code
github micro-fan / aiozk / aiozk / exc.py View on Github external
pass


class InvalidClientState(ZKError):
    pass


class TimeoutError(ZKError):
    pass


class UnfinishedRead(ZKError):
    pass


class FailedRetry(ZKError):
    pass


class InvalidStateTransition(ZKError):
    pass


response_error_xref = {}


class ResponseErrorMeta(type):

    def __new__(cls, name, bases, attrs):
        new_class = super(ResponseErrorMeta, cls).__new__(
            cls, name, bases, attrs
        )