Allow wss_timeout=None to disable timeout on reconnection.

This commit is contained in:
Davide Casale
2023-04-20 01:26:25 +02:00
parent 92d6630013
commit 99783c1a5a
2 changed files with 9 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import List, Literal, Optional
from .rest import BfxRestInterface
from .websocket import BfxWebsocketClient
@@ -13,9 +13,9 @@ class Client:
*,
rest_host: str = REST_HOST,
wss_host: str = WSS_HOST,
wss_timeout: float = 60 * 15,
wss_timeout: Optional[float] = 60 * 15,
log_filename: Optional[str] = None,
log_level: str = "INFO"
log_level: Literal["ERROR", "WARNING", "INFO", "DEBUG"] = "INFO"
):
credentials = None

View File

@@ -129,7 +129,8 @@ class BfxWebsocketClient:
reconnection = Reconnection(status=False, attempts=0, timestamp=None)
timer.cancel()
if isinstance(timer, asyncio.events.TimerHandle):
timer.cancel()
self.websocket = websocket
@@ -198,7 +199,10 @@ class BfxWebsocketClient:
task.cancel()
reconnection = Reconnection(status=True, attempts=1, timestamp=datetime.now())
timer = asyncio.get_event_loop().call_later(self.wss_timeout, _on_wss_timeout)
if self.wss_timeout is not None:
timer = asyncio.get_event_loop().call_later(self.wss_timeout, _on_wss_timeout)
delay = _Delay(backoff_factor=1.618)
self.authentication = False