Skip to content

Commit

Permalink
more linting
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone committed Jan 7, 2025
1 parent 58dadc5 commit 854052d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 854052d

Please sign in to comment.