zincware / ZnSocket

Python implementation of a Redis-compatible API using websockets.
Apache License 2.0
2 stars 2 forks source link

configure timeout and retries #81

Closed PythonFZ closed 1 week ago

PythonFZ commented 1 week ago

For slow connections or many connection attempts this can timeout

https://github.com/zincware/ZnSocket/blob/042bed91e503988a64c176302daaf4fe0420acee/znsocket/client.py#L103

and it would be nice to configure this. Also add a minimal delay between calls as option to not overwhelm the server.

Traceback (most recent call last):
  File "/Users/fzills/tools/ZnDraw/examples/stress_testing.py", line 13, in <module>
    vis.append(atoms)
  File "<frozen _collections_abc>", line 1078, in append
  File "/Users/fzills/tools/ZnDraw/zndraw/zndraw.py", line 292, in __len__
    return len(
           ^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/zndraw/lib/python3.11/site-packages/znsocket/objects/__init__.py", line 133, in __len__
    return int(self.redis.llen(self.key))
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/zndraw/lib/python3.11/site-packages/znsocket/client.py", line 103, in _redis_command
    result = self.sio.call(command, [args, kwargs], namespace=self.namespace)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/zndraw/lib/python3.11/site-packages/socketio/client.py", line 292, in call
    raise exceptions.TimeoutError()
socketio.exceptions.TimeoutError