crypto-ws-api 2.1.3__tar.gz → 2.1.4__tar.gz
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.
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/CHANGELOG.md +6 -0
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/PKG-INFO +1 -1
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/crypto_ws_api/__init__.py +1 -1
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/crypto_ws_api/ws_session.py +11 -1
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/.deepsource.toml +0 -0
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/LICENSE.md +0 -0
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/README.md +0 -0
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/crypto_ws_api/demo.py +0 -0
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/crypto_ws_api/ws_api.toml.template +0 -0
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/pyproject.toml +0 -0
- {crypto_ws_api-2.1.3 → crypto_ws_api-2.1.4}/requirements.txt +0 -0
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 2.1.4 - 2025-12-02
|
|
2
|
+
- Add optional root logger configuration to set_logger()
|
|
3
|
+
- Introduce malloc_trim() wrapper for C library memory management
|
|
4
|
+
- Invoke malloc_trim() in WSSession cleanup for memory optimization
|
|
5
|
+
- Update __init__.py and CHANGELOG.md for version 2.1.4
|
|
6
|
+
|
|
1
7
|
## 2.1.3 - 2025-10-16
|
|
2
8
|
✨ feat(ws_session.py): Add `tasks_cancel()` for structured task cancellation with logging
|
|
3
9
|
♻️ refactor(ws_session.py): Refactor task cancellation and stop logic to use `tasks_cancel()`
|
|
@@ -13,7 +13,7 @@ __maintainer__ = "Jerry Fedorenko"
|
|
|
13
13
|
__contact__ = "https://github.com/DogsTailFarmer"
|
|
14
14
|
__email__ = "jerry.fedorenko@yahoo.com"
|
|
15
15
|
__credits__ = ["https://github.com/DanyaSWorlD"]
|
|
16
|
-
__version__ = "2.1.
|
|
16
|
+
__version__ = "2.1.4"
|
|
17
17
|
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
import shutil
|
|
@@ -17,6 +17,7 @@ from datetime import datetime, timezone
|
|
|
17
17
|
from urllib.parse import urlencode, urlparse
|
|
18
18
|
from cryptography.hazmat.primitives.serialization import load_pem_private_key
|
|
19
19
|
import inspect
|
|
20
|
+
import ctypes, ctypes.util
|
|
20
21
|
|
|
21
22
|
from websockets.asyncio.client import connect
|
|
22
23
|
from websockets import ConnectionClosed
|
|
@@ -31,7 +32,7 @@ sys.tracebacklimit = 0
|
|
|
31
32
|
ALPHABET = string.ascii_letters + string.digits
|
|
32
33
|
CONST_WS_START = "userDataStream.start"
|
|
33
34
|
|
|
34
|
-
def set_logger(name, log_file, file_level=logging.INFO, propagate=False):
|
|
35
|
+
def set_logger(name, log_file, file_level=logging.INFO, propagate=False, set_root_logger=False):
|
|
35
36
|
formatter = logging.Formatter(fmt="[%(asctime)s: %(levelname)s] %(message)s")
|
|
36
37
|
#
|
|
37
38
|
fh = logging.handlers.RotatingFileHandler(log_file, maxBytes=1000000, backupCount=10)
|
|
@@ -47,10 +48,18 @@ def set_logger(name, log_file, file_level=logging.INFO, propagate=False):
|
|
|
47
48
|
_logger.addHandler(sh)
|
|
48
49
|
_logger.propagate = propagate
|
|
49
50
|
|
|
51
|
+
if set_root_logger:
|
|
52
|
+
root_logger = logging.getLogger()
|
|
53
|
+
root_logger.setLevel(min([fh.level, sh.level]))
|
|
54
|
+
root_logger.addHandler(fh)
|
|
55
|
+
root_logger.addHandler(sh)
|
|
56
|
+
|
|
50
57
|
return _logger
|
|
51
58
|
|
|
52
59
|
logger = set_logger(__name__, Path(LOG_PATH, 'ws_session.log'))
|
|
53
60
|
|
|
61
|
+
def malloc_trim(trim_type: int = 0):
|
|
62
|
+
ctypes.CDLL(ctypes.util.find_library('c')).malloc_trim(trim_type)
|
|
54
63
|
|
|
55
64
|
def generate_signature(exchange: str, secret: str, data: str) -> str:
|
|
56
65
|
encoding = "utf-8"
|
|
@@ -225,6 +234,7 @@ class UserWSS:
|
|
|
225
234
|
await tasks_cancel(self.tasks, _logger=self.logger)
|
|
226
235
|
self._response_pool.clear()
|
|
227
236
|
gc.collect()
|
|
237
|
+
malloc_trim()
|
|
228
238
|
|
|
229
239
|
async def start_wss(self):
|
|
230
240
|
async for self._ws in connect(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|