Skip to content

Commit

Permalink
Catch retry exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Jun 15, 2023
1 parent 839626b commit b145670
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion siridb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version_info__ = (2, 1, 2)
__version_info__ = (2, 1, 3)
__version__ = '.'.join(map(str, __version_info__))
__maintainer__ = 'Jeroen van der Heijden'
__email__ = 'jeroen@cesbit.com'
8 changes: 5 additions & 3 deletions siridb/connector/lib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import random
from .protocol import _SiriDBProtocol, _SiriDBConnProtocol
from .connection import SiriDBAsyncConnection
from .exceptions import AuthenticationError
from .exceptions import ServerError
from .exceptions import PoolError
from .constants import SECOND
Expand Down Expand Up @@ -331,7 +330,7 @@ class SiriDBConn:

MAX_RECONNECT_WAIT_TIME = 60
MAX_RECONNECT_TIMEOUT = 10
MAX_WRITE_RETRY = 600
MAX_WRITE_RETRY = 120
RECONNECT_ATTEMPT = 3

def __init__(self,
Expand Down Expand Up @@ -460,7 +459,10 @@ async def _ensure_write(
try:
res = await self._protocol.send_package(
tipe, data, is_binary, timeout)
except Exception as e:
except (ServerError,
PoolError,
OSError,
asyncio.TimeoutError) as e:
if retry > self.MAX_WRITE_RETRY:
raise e
if retry % self.RECONNECT_ATTEMPT == 0:
Expand Down

0 comments on commit b145670

Please sign in to comment.