Open bairavand opened 1 year ago
Did you manage to find a solution yet? Im running into the same issue
I didn't find any solution yet. I planned to switch to an another library called binance-connector which is currently supporting Python 3.10 and also it's an official Binance library.
Another user opened issue https://github.com/sammchardy/python-binance/issues/1354 that seems related.
@bairavand Do you also have an instance of ThreadedDepthCacheManager in your application?
With the simple script like below I get the same error, but not the ThreadedDepthCacheManager
one. Also no scripts from the examples work for me giving the same error.
import time
from binance import ThreadedWebsocketManager
def on_message(message):
event_time = message['data']['E']
close_time = message['data']['k']['T']
close_price = message['data']['k']['c']
print(f"Event Time: {event_time}, Close Time: {close_time}, Close Price: {close_price}")
symbol = 'BNBBTC'
interval = '1m'
twm = ThreadedWebsocketManager(api_key=api_key, api_secret=api_secret)
twm.start()
twm.start_kline_socket(callback=on_message, symbol=symbol)
twm.join()
while True:
time.sleep(1)
Exception in thread Thread-5: Traceback (most recent call last): File "C:\ProgramData\miniconda3\envs\streams\lib\threading.py", line 1016, in _bootstrap_inner self.run() File "C:\ProgramData\miniconda3\envs\streams\lib\site-packages\binance\threaded_stream.py", line 56, in run self._loop.run_until_complete(self.socket_listener()) File "C:\ProgramData\miniconda3\envs\streams\lib\asyncio\base_events.py", line 625, in run_until_complete self._check_running() File "C:\ProgramData\miniconda3\envs\streams\lib\asyncio\base_events.py", line 584, in _check_running raise RuntimeError('This event loop is already running') RuntimeError: This event loop is already running C:\ProgramData\miniconda3\envs\streams\lib\threading.py:1018: RuntimeWarning: coroutine 'ThreadedApiManager.socket_listener' was never awaited self._invoke_excepthook(self) RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Describe the bug I was using python-binance with Python 3.7 and it was working fine. I upgraded Python version to 3.10 and I unable to get websocket response. I also tried with Python 3.8 that is also not working. Is there any way to handle it?
To Reproduce Code snippet to reproduce the behavior:
Expected behavior Inside the while loop the trade response should come whenever a trade happens on Binance. but after upgraded to Python 3.10 the response is not triggered and I didn't receive any error. Environment:
Logs or Additional context I didn't receive the websocket response. Other than that, there is no specific error