Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated loop in code #5

Open
adsjr1 opened this issue Sep 4, 2022 · 1 comment
Open

Deprecated loop in code #5

adsjr1 opened this issue Sep 4, 2022 · 1 comment

Comments

@adsjr1
Copy link

adsjr1 commented Sep 4, 2022

Tried to run the basic example for a market subscription, but I am getting this error:
/workspaces/ft_userdata/user_data/tradingbot/bot.py:16:`` DeprecationWarning: There is no current event loop loop = asyncio.get_event_loop() INFO:client:Connecting to wss://stream.crypto.com/v2/market Traceback (most recent call last): File "/workspaces/ft_userdata/user_data/tradingbot/bot.py", line 17, in <module> loop.run_until_complete(run()) File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete return future.result() File "/workspaces/ft_userdata/user_data/tradingbot/bot.py", line 8, in run async with MarketClient() as client: File "/home/ftuser/.local/lib/python3.10/site-packages/crypto_com/crypto_com.py", line 65, in __aenter__ self.websocket = await websockets.connect(self.api_url) File "/home/ftuser/.local/lib/python3.10/site-packages/websockets/client.py", line 535, in __await_impl__ transport, protocol = await self._create_connection() File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection transport, protocol = await self._create_connection_transport( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1107, in _create_connection_transport protocol = protocol_factory() File "/home/ftuser/.local/lib/python3.10/site-packages/websockets/client.py", line 69, in __init__ super().__init__(**kwargs) File "/home/ftuser/.local/lib/python3.10/site-packages/websockets/protocol.py", line 235, in __init__ self._drain_lock = asyncio.Lock( File "/usr/local/lib/python3.10/asyncio/locks.py", line 78, in __init__ super().__init__(loop=loop) File "/usr/local/lib/python3.10/asyncio/mixins.py", line 17, in __init__ raise TypeError( TypeError: As of 3.10, the *loop* parameter was removed from Lock() since it is no longer necessary

This is the code I am running with python 3.9:
`from crypto_com.crypto_com import MarketClient
import asyncio
import logging

logging.basicConfig(level=logging.INFO)

async def run():
async with MarketClient() as client:
await client.subscribe(["book.CRO_USDC.10"])
while True:
event = await client.next_event()
print(event)

if name == "main":
loop = asyncio.get_event_loop()
loop.run_until_complete(run())`

@maxpowel
Copy link
Owner

maxpowel commented Feb 8, 2024

Probably it is due an old version of websockets library. You traceback points to /home/ftuser/.local/lib/python3.10/site-packages/websockets/protocol.py.

I'm not getting any issue but I upgraded to the latest websocket version anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants