From efcc4c6adec5ece72efe395eb35ffc210266c026 Mon Sep 17 00:00:00 2001 From: ATATC Date: Fri, 15 Dec 2023 13:42:28 -0500 Subject: [PATCH] Bug fixed: remote server does not shut down when the window is closed. Routine updates. --- leads/utils.py | 18 ++++++++++++++++++ leads_dashboard/__init__.py | 1 + 2 files changed, 19 insertions(+) diff --git a/leads/utils.py b/leads/utils.py index b6ee17ec..ebf89dbb 100644 --- a/leads/utils.py +++ b/leads/utils.py @@ -11,6 +11,12 @@ def mean_compressor(sequence: list[T], target_size: int) -> list[T]: + """ + A compression method that reduces data memory usage by averaging adjacent numbers and merging them. + :param sequence: the sequence to compress + :param target_size: expected size + :return: the compressed sequence + """ chunk_size = int(len(sequence) / target_size) if chunk_size < 2: return sequence @@ -22,6 +28,11 @@ def mean_compressor(sequence: list[T], target_size: int) -> list[T]: def csv_stringifier(element: T) -> str: + """ + Dump an element as a CSV string. + :param element: the element to stringify + :return: CSV string + """ return str(element) + "," @@ -32,6 +43,13 @@ def __init__(self, chunk_scale: int = 1, compressor: Compressor = mean_compressor, stringifier: Stringifier = csv_stringifier) -> None: + """ + :param file: the file into which the data is written + :param max_size: maximum cached size + :param chunk_scale: chunk scaling factor (compression) + :param compressor: compressor interface + :param stringifier: stringifier interface + """ self._file: _TextIO = open(file, "a") if isinstance(file, str) else file self._max_size: int = max_size self._chunk_scale: int = chunk_scale diff --git a/leads_dashboard/__init__.py b/leads_dashboard/__init__.py index 4d64521b..2b311d97 100644 --- a/leads_dashboard/__init__.py +++ b/leads_dashboard/__init__.py @@ -66,3 +66,4 @@ def start_comm_server(render: _Callable[[], None], server: _Server = _create_ser server.start(True) _dpg.start_dearpygui() _dpg.destroy_context() + server.kill()