Skip to content

Commit

Permalink
Random cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoscon committed Nov 21, 2024
1 parent 90ebe02 commit 2b9d315
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cryptofeed/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from aiohttp.client_reqrep import ClientResponse
import requests
from websockets.asyncio.client import connect
from websockets.asyncio.client import connect, ClientConnection
from websockets.protocol import State
import aiohttp
from aiohttp.typedefs import StrOrURL
Expand Down Expand Up @@ -82,7 +82,7 @@ def __init__(self, conn_id: str, authentication=None, subscription=None):
self.last_message = None
self.authentication = authentication
self.subscription = subscription
self.conn: Union[websockets.WebSocketClientProtocol, aiohttp.ClientSession] = None
self.conn: Union[ClientConnection, aiohttp.ClientSession] = None
atexit.register(self.__del__)

def __del__(self):
Expand Down
3 changes: 0 additions & 3 deletions cryptofeed/connection_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
'''
import asyncio
import logging
import random
from socket import error as socket_error
import time
from typing import Awaitable
Expand Down Expand Up @@ -51,7 +50,6 @@ async def _watcher(self):
async def _create_connection(self):
await asyncio.sleep(self.start_delay)
retries = 0
rate_limited = 1
delay = 1
while (retries <= self.retries or self.retries == -1) and self.running:
try:
Expand All @@ -60,7 +58,6 @@ async def _create_connection(self):
await self.subscribe(connection)
# connection was successful, reset retry count and delay
retries = 0
rate_limited = 0
delay = 1
if self.timeout != -1:
loop = asyncio.get_running_loop()
Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/exchanges/kucoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ async def subscribe(self, conn: AsyncConnection):
await conn.write(json.dumps({
'id': 1,
'type': 'subscribe',
'topic': f"{chan}:{','.join(symbols[slice_index: slice_index+100])}",
'topic': f"{chan}: {','.join(symbols[slice_index: slice_index + 100])}",
'privateChannel': False,
'response': True
}))
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ order_book==0.6.1
pyyaml
requests>=2.18.4
uvloop
websockets>=7.0
websockets>=14.1
yapic.json>=1.6.3
2 changes: 1 addition & 1 deletion tools/websockets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ async def main():
if not is_gzip:
print(f"< {response}")
else:
print(f"< {zlib.decompress(response, 16+zlib.MAX_WBITS)}")
print(f"< {zlib.decompress(response, 16 + zlib.MAX_WBITS)}")

asyncio.get_event_loop().run_until_complete(main())

0 comments on commit 2b9d315

Please sign in to comment.