clear exceptions atexit

This commit is contained in:
Danglewood
2024-11-10 12:45:17 -08:00
parent 82b706a41e
commit 2489128b67
2 changed files with 8 additions and 2 deletions

View File

@@ -166,6 +166,8 @@ class WebSocketClient:
# pylint: disable=import-outside-toplevel
import os
self._exception = None
if self.is_running:
self.disconnect()
if self.is_broadcasting:

View File

@@ -60,7 +60,6 @@ async def create_connection(
if not client.is_running:
if client._exception:
exc = getattr(client, "_exception", None)
delattr(client, "_exception")
client._atexit()
if isinstance(exc, UnauthorizedError):
raise exc
@@ -159,14 +158,19 @@ async def subscribe(
"""
if not await check_auth(name, auth_token):
raise OpenBBError("Error finding client.")
client = connected_clients[name]
symbols = client.symbol.split(",")
if symbols and symbol in symbols:
raise OpenBBError(f"Client {name} already subscribed to {symbol}.")
client.subscribe(symbol)
# await asyncio.sleep(2)
await asyncio.sleep(1)
if client.is_running:
return OBBject(results=f"Added {symbol} to client {name} connection.")
client.logger.error(
f"Client {name} failed to subscribe to {symbol} and is not running."
)