leantext 1.0.6__cp38-abi3-win_amd64.whl → 1.1.1__cp38-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
leantext/leantext.pyd
CHANGED
|
Binary file
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
leantext\__init__.py,sha256=gc6BKLkTF6zMXaN3OGq2DJkxElZCxkvsVBd0G2IG8jc,115
|
|
2
|
+
leantext\leantext.pyd,sha256=lHDdtqLu6M1pJauANzjoasrw5LQinFy-SLH7cxtFF4o,2352640
|
|
3
|
+
leantext-1.1.1.dist-info\METADATA,sha256=pD290rJ65zQTlFOm3iHjYx7IlY24IvAPvnvgtVoH65E,628
|
|
4
|
+
leantext-1.1.1.dist-info\WHEEL,sha256=gPqN4EsdiAyGvmfrYy_ONrF276O8o0hPitI2CKZrEFA,95
|
|
5
|
+
leantext_engine.py,sha256=qx8GNnW3zkOCBI524iiKHIwgkkIBE61J_i-pSqhq9PQ,26843
|
|
6
|
+
leantext-1.1.1.dist-info\RECORD,,
|
leantext_engine.py
CHANGED
|
@@ -5,6 +5,8 @@ import re
|
|
|
5
5
|
import leantext
|
|
6
6
|
import atexit
|
|
7
7
|
import gc
|
|
8
|
+
import signal
|
|
9
|
+
import sys
|
|
8
10
|
import time
|
|
9
11
|
import threading
|
|
10
12
|
import copy
|
|
@@ -131,6 +133,7 @@ class LeanTextEngine:
|
|
|
131
133
|
"""
|
|
132
134
|
self.base_path = base_path
|
|
133
135
|
self.thread_safe = thread_safe
|
|
136
|
+
self._is_closed = False
|
|
134
137
|
|
|
135
138
|
if not os.path.exists(base_path):
|
|
136
139
|
os.makedirs(base_path)
|
|
@@ -154,7 +157,17 @@ class LeanTextEngine:
|
|
|
154
157
|
self.m_thread.start()
|
|
155
158
|
|
|
156
159
|
if auto_persist:
|
|
157
|
-
|
|
160
|
+
# Register for standard exit
|
|
161
|
+
atexit.register(self.close)
|
|
162
|
+
# Register for SIGTERM (Docker/Kubernetes/IDE Stop)
|
|
163
|
+
signal.signal(signal.SIGTERM, self._handle_signal)
|
|
164
|
+
# Register for SIGINT (Ctrl+C)
|
|
165
|
+
signal.signal(signal.SIGINT, self._handle_signal)
|
|
166
|
+
|
|
167
|
+
def _handle_signal(self, signum, frame):
|
|
168
|
+
"""Handle signals by closing gracefully."""
|
|
169
|
+
self.close()
|
|
170
|
+
sys.exit(0)
|
|
158
171
|
|
|
159
172
|
def _get_col_path(self, name: str) -> str:
|
|
160
173
|
return os.path.join(self.base_path, name)
|
|
@@ -655,8 +668,20 @@ class LeanTextEngine:
|
|
|
655
668
|
self.local_versions[collection] = tracker.get_version()
|
|
656
669
|
|
|
657
670
|
def close(self):
|
|
658
|
-
"""Gracefully close
|
|
671
|
+
"""Gracefully close: stop thread, then persist."""
|
|
672
|
+
if self._is_closed:
|
|
673
|
+
return
|
|
674
|
+
|
|
659
675
|
self.stop_maintenance = True
|
|
660
|
-
if self.m_thread.is_alive():
|
|
661
|
-
|
|
662
|
-
|
|
676
|
+
if self.m_thread.is_alive() and self.m_thread is not threading.current_thread():
|
|
677
|
+
try:
|
|
678
|
+
self.m_thread.join(timeout=2.0)
|
|
679
|
+
except RuntimeError:
|
|
680
|
+
pass
|
|
681
|
+
|
|
682
|
+
try:
|
|
683
|
+
self.persist_all()
|
|
684
|
+
except Exception as e:
|
|
685
|
+
sys.stderr.write(f"Error saving data on exit: {e}\n")
|
|
686
|
+
|
|
687
|
+
self._is_closed = True
|
leantext-1.0.6.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
leantext\__init__.py,sha256=gc6BKLkTF6zMXaN3OGq2DJkxElZCxkvsVBd0G2IG8jc,115
|
|
2
|
-
leantext\leantext.pyd,sha256=df0xphI176EI6ghW97-tGtzACD3QDjg_ZYnTAqqk9Rk,2405376
|
|
3
|
-
leantext-1.0.6.dist-info\METADATA,sha256=ma0e0yLdVifvrHo-P-JKquLBQg_8kUnUf88BQgMBtgA,628
|
|
4
|
-
leantext-1.0.6.dist-info\WHEEL,sha256=gPqN4EsdiAyGvmfrYy_ONrF276O8o0hPitI2CKZrEFA,95
|
|
5
|
-
leantext_engine.py,sha256=YNpsg2vNR-5NW3LgvtxzW3I-kKKQrZwAqMKlFT_id3g,25997
|
|
6
|
-
leantext-1.0.6.dist-info\RECORD,,
|
|
File without changes
|