python - ThreadedWebsocketManager - task exception was never retrieved

Viewed 577

I'm trying to run the following code from tutorial that I found on jupyter notebook:

from time import sleep

from binance import ThreadedWebsocketManager

btc_price = {'error':False}

def btc_trade_history(msg):

    if (msg['e'] != 'error'):

        print(msg['c'])

        btc_price['last'] = msg['c']

        btc_price['bid'] = msg['b']

        btc_price['last'] = msg['a']

        btc_price['error'] = False

    else:

        btc_price['error'] = True

bsm = ThreadedWebsocketManager()

bsm.start()

bsm.start_symbol_ticker_socket(callback=btc_trade_history, symbol='BTCUSDT')

here is the link to the tutorial itself: https://algotrading101.com/learn/binance-python-api-guide/

I guess, since the tutorial was written, something was changed in binance API, so I get the following error:

CANCEL read_loop Task exception was never retrieved future: <Task finished name='Task-14' coro=<ThreadedApiManager.start_listener() done, defined at C:\Users\myusername\Anaconda3\lib\site-packages\binance\threaded_stream.py:42> exception=RuntimeError("Task <Task pending name='Task-20' coro=<Queue.get() running at C:\Users\myusername\Anaconda3\lib\asyncio\queues.py:163> cb=[_release_waiter(()]>)() at C:\Users\myusername\Anaconda3\lib\asyncio\tasks.py:429]> got Future attached to a different loop")>

Please, explain what's going wrong and how do I fix it?

2 Answers

There is a discussion on this issue.

Unfortunately, the library python-binance rarely receives updates. It seems that we should not expect a solution to the problem in the near future.

Use the version 1.0.15 instead of 1.0.16

Related