Skip to content

Commit

Permalink
Bug fixed: remote server does not shut down when the window is closed.
Browse files Browse the repository at this point in the history
Routine updates.
  • Loading branch information
ATATC committed Dec 15, 2023
1 parent c1d71de commit efcc4c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions leads/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) + ","


Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions leads_dashboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit efcc4c6

Please sign in to comment.