python-binance
python-binance copied to clipboard
'coroutine' object has no attribute 'tld' when start AsyncClient.create()
Describe the bug I see that package was upgrade to new version with changing in the way to use web socket stream data.
I try to new the new with your guide but get this error 'coroutine' object has no attribute 'tld' when run AsyncClient.create() to create new connect to wss.
To Reproduce client = AsyncClient.create(api_key=API,api_secret=SEC,tld='com') bm = BinanceSocketManager(client)
Get error at second line:
AttributeError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/binance/streams.py in init(self, client, loop, user_timeout) 256 257 """ --> 258 self.STREAM_URL = self.STREAM_URL.format(client.tld) 259 self.FSTREAM_URL = self.FSTREAM_URL.format(client.tld) 260 self.DSTREAM_URL = self.DSTREAM_URL.format(client.tld)
AttributeError: 'coroutine' object has no attribute 'tld'
Environment (please complete the following information):
- Python version: [e.g. 3.5]
- Virtual Env: Google Colab
- python-binance version (1.0.4)
Hope u can fix it soon. Thanks alot
Hello,
Same problem for me with this upgrade, i rollback :(
It is possible to have a complete example, how to use websockets with this new version? What is the reason of this big change? future compatibility with Binance?
i search to convert "start_multiplex_socket" with this new version.
Regards.
@hoangdh5 you need to await
the AsyncClient.create
call like
client = await AsyncClient.create(api_key=API,api_secret=SEC,tld='com')
There are examples in the websockets docs https://python-binance.readthedocs.io/en/latest/websockets.html
The change was to remove Tornado and autobahn legacy dependencies that caused pain for a lot of people trying to isntall it.
Instead using websockets and asyncio.
Could u help to creat a full sample load data from this new.
I run sample but still get error:
------------------ Code ------------------ I just run the example from your guideline in colab: https://python-binance.readthedocs.io/en/latest/websockets.html
------------------ Error ------------------
RuntimeError Traceback (most recent call last)
1 frames /usr/lib/python3.7/asyncio/base_events.py in run_until_complete(self, future) 561 """ 562 self._check_closed() --> 563 self._check_runnung() 564 565 new_task = not futures.isfuture(future)
/usr/lib/python3.7/asyncio/base_events.py in _check_runnung(self) 521 def _check_runnung(self): 522 if self.is_running(): --> 523 raise RuntimeError('This event loop is already running') 524 if events._get_running_loop() is not None: 525 raise RuntimeError(
RuntimeError: This event loop is already running
Can you format your code a little better please.
i also got the error ( RuntimeError 'This event loop is already running') when i use the Spyder IDE. When I run the sample from the terminal the error message no longer comes. Maybe this helps...
Can you format your code a little better please.
Sorry i just get code from example.
Alternatively you can use the ThreadedWebsocketManager class which abstracts away any asyncio requirements for you.
some examples here in the docs https://python-binance.readthedocs.io/en/latest/websockets.html
i also got the error ( RuntimeError 'This event loop is already running') when i use the Spyder IDE. When I run the sample from the terminal the error message no longer comes. Maybe this helps...
try add this, see if it helps
import nest_asyncio nest_asyncio.apply()