Fixed huge memory leak caused by httpx

api-breakage
Morty Space 4 years ago
parent 29c3e84946
commit a92b1d69a2
  1. 3
      README.md
  2. 2
      src/cryptocom/exchange/__init__.py
  3. 9
      src/cryptocom/exchange/api.py

@ -15,6 +15,8 @@ Documentation: [https://cryptocom-exchange.rtfd.io](https://cryptocom-exchange.r
Exchange original API docs: [https://exchange-docs.crypto.com](https://exchange-docs.crypto.com)
### **WARNING: PLEASE use 0.10.2+ or up to 0.9.5 version because of httpx memory leak** [0.10, 0.10.1] -> are broken
### Description
`pip install cryptocom-exchange`
@ -27,6 +29,7 @@ Exchange original API docs: [https://exchange-docs.crypto.com](https://exchange-
### Changelog
- **0.10.2** - fixed huge memory leak by `httpx`
- **0.10.1** - added read timeouts for websockets, fixed test with tickers
- **0.10.0** - moved into httpx + websockets, added autoreconnect, simplified code, improved stability
- **0.9.5** - added timeout for websocket if no data received in 3 mins we trying to reconnect

@ -23,4 +23,4 @@ __all__ = [
'ApiError', 'ApiProvider'
]
__version__ = '0.10.1'
__version__ = '0.10.2'

@ -117,7 +117,6 @@ class ApiListenAsyncIterable:
self.sub_data_sent = True
class ApiProvider:
"""Provides HTTP-api requests and websocket requests."""
def __init__(
@ -125,7 +124,7 @@ class ApiProvider:
auth_required=True, timeout=25, retries=6,
root_url='https://api.crypto.com/v2/',
ws_root_url='wss://stream.crypto.com/v2/', logger=None):
self.ssl_context = httpx.create_ssl_context()
self.api_key = api_key
self.api_secret = api_secret
self.root_url = root_url
@ -203,7 +202,9 @@ class ApiProvider:
for count in range(self.retries + 1):
client = httpx.AsyncClient(
timeout=httpx.Timeout(timeout=self.timeout))
timeout=httpx.Timeout(timeout=self.timeout),
verify=self.ssl_context
)
if sign:
data = self.sign(path, original_data)
try:
@ -231,7 +232,7 @@ class ApiProvider:
if resp.status_code == 429:
continue
raise ApiError(
f"Can't decode json, content: {resp.text()}. "
f"Can't decode json, content: {resp.text}. "
f"Code: {resp.status_code}")
finally:
await client.aclose()

Loading…
Cancel
Save