Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Improve error handling when reconnecting to ZooKeeper #515

@eliska-n

Description

@eliska-n

Reconnecting to ZooKeeper works nicely, but it is quite "loud" in the logs.
There are uncaught exceptions propagated when ZooKeeper is not reachable.

Task exception was never retrieved
{'future': <Task finished name='Task-440' coro=<ZooKeeperContainer._readvertise() done, defined at /usr/local/lib/python3.11/dist-packages/asab/zookeeper/container.py:163> exception=SessionExpiredError()>}
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/asab/zookeeper/container.py", line 165, in _readvertise
    await adv._readvertise(self)
  File "/usr/local/lib/python3.11/dist-packages/asab/zookeeper/container.py", line 231, in _readvertise
    await zoocontainer.ZooKeeper.ProactorService.execute(check_at_zk)
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/asab/zookeeper/container.py", line 225, in check_at_zk
    if zoocontainer.ZooKeeper.Client.exists(self.RealPath):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/kazoo/client.py", line 1123, in exists
    return self.exists_async(path, watch=watch).get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/kazoo/handlers/utils.py", line 86, in get
    raise self._exception
kazoo.exceptions.SessionExpiredError

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions