diff --git a/openbb_platform/core/openbb_core/provider/utils/websockets/broadcast.py b/openbb_platform/core/openbb_core/provider/utils/websockets/broadcast.py index fdd6e9bf7214..62ef54fcaadd 100644 --- a/openbb_platform/core/openbb_core/provider/utils/websockets/broadcast.py +++ b/openbb_platform/core/openbb_core/provider/utils/websockets/broadcast.py @@ -215,7 +215,7 @@ def _decrypt_value(self, value: str) -> str: async def stream_results( # noqa: PLR0915 # pylint: disable=too-many-branches self, - sql: str = None, + sql: Optional[str] = None, replay: bool = False, ): """Continuously read the database and send new messages as JSON via WebSocket.""" @@ -283,7 +283,7 @@ async def stream_results( # noqa: PLR0915 # pylint: disable=too-many-branches continue for row in rows: last_id = row[0] if row[0] > last_id else last_id - await self.websocket.send_json( + await self.websocket.send_json( # type: ignore json.dumps(json.loads(row[1])) ) if self.replay is True: # type: ignore diff --git a/openbb_platform/core/openbb_core/provider/utils/websockets/database.py b/openbb_platform/core/openbb_core/provider/utils/websockets/database.py index 4e380c3b5531..19f41a7bcc85 100644 --- a/openbb_platform/core/openbb_core/provider/utils/websockets/database.py +++ b/openbb_platform/core/openbb_core/provider/utils/websockets/database.py @@ -244,7 +244,7 @@ async def get_connection(self, name: str = "read"): if name == "read": if ":" not in self.results_file: # type: ignore results_file = ( # type: ignore - "file:" + "file:" # type: ignore + ( self.results_file # type: ignore if self.results_file.startswith("/") # type: ignore @@ -506,6 +506,7 @@ def query(self, sql: str, parameters: Optional[Iterable[Any]] = None) -> list: except Exception as e: # pylint: disable=broad-except msg = f"{e.__class__.__name__ if hasattr(e, '__class__') else e}: {e.args}" self.logger.error(msg) + return [] async def _clear_results(self): """Clear the results from the SQLite database.""" @@ -951,17 +952,17 @@ def start_prune_task(self): prune_thread = threading.Thread(target=self._run_prune_event) prune_thread.daemon = True prune_thread.name = "WebSocketPruneThread" - self.prune_thread = prune_thread - self.prune_thread.start() + self.prune_thread = prune_thread # type: ignore + self.prune_thread.start() # type: ignore finally: - self.prune_thread.join(timeout=1) + self.prune_thread.join(timeout=1) # type: ignore def stop_prune_task(self): """Public method to stop the background pruning task.""" if hasattr(self, "prune_thread") and self.prune_thread: - self.prune_thread.join(timeout=1) - if self.prune_thread.is_alive(): - kill_thread(self.prune_thread) + self.prune_thread.join(timeout=1) # type: ignore + if self.prune_thread.is_alive(): # type: ignore + kill_thread(self.prune_thread) # type: ignore self._prune_running = False self.prune_thread = None