Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 13, 2024
1 parent 6d153ed commit 2e82321
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions znsocket/client.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import dataclasses
import datetime
import functools
import json
import logging
import typing as t
import warnings
import datetime

import socketio.exceptions
import typing_extensions as tyex
Expand Down Expand Up @@ -51,7 +51,7 @@ def _handle_error(result):
@dataclasses.dataclass
class Client:
"""Client to interact with a znsocket server.
Attributes
----------
address : str
Expand All @@ -67,6 +67,7 @@ class Client:
delay_between_calls : datetime.timedelta
The time to wait between calls. Default is None.
"""

address: str
decode_responses: bool = True
sio: socketio.Client = dataclasses.field(
Expand All @@ -75,7 +76,7 @@ class Client:
namespace: str = "/znsocket"
refresh_callbacks: dict = dataclasses.field(default_factory=dict)
retry: int = 3
delay_between_calls: datetime.timedelta|None = None
delay_between_calls: datetime.timedelta | None = None

_last_call: datetime.datetime = dataclasses.field(
default_factory=datetime.datetime.now, init=False
Expand Down Expand Up @@ -121,7 +122,6 @@ def refresh(data: RefreshDataTypeDict):

if not self.decode_responses:
raise NotImplementedError("decode_responses=False is not supported yet")


def call(self, event: str, data: t.Any) -> t.Any:
"""Call an event on the server."""
Expand All @@ -138,9 +138,7 @@ def call(self, event: str, data: t.Any) -> t.Any:
except socketio.exceptions.TimeoutError:
if idx == 0:
raise
log.warning(
f"Connection error. Retrying... {idx} attempts left"
)
log.warning(f"Connection error. Retrying... {idx} attempts left")
self.sio.sleep(1)

def _redis_command(self, command, *args, **kwargs):
Expand Down

0 comments on commit 2e82321

Please sign in to comment.