Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

ThreadedWebsocketManager()

Aperta
#1,409 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@pcriadoperez ci sta già lavorando.

Dal 24/10/2024.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Describe the bug
I'm using python-binance's example of a threaded websocket manager, to retrieve BTCUSDT prices. When running the script within jupyter lab i receive the follwoing RuntimeError:Exception in thread Thread-9:
Traceback (most recent call last):
File "C:\Users\pb\Documents\Python_Anaconda3\envs\CryptoPredictor\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\pb\Documents\Python_Anaconda3\envs\CryptoPredictor\lib\site-packages\binance\threaded_stream.py", line 59, in run
self._loop.run_until_complete(self.socket_listener())
File "C:\Users\pb\Documents\Python_Anaconda3\envs\CryptoPredictor\lib\asyncio\base_events.py", line 625, in run_until_complete
self._check_running()
File "C:\Users\pb\Documents\Python_Anaconda3\envs\CryptoPredictor\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

If running it in PyCharm i don't receive any errors but also no output and nothing seems to be happening.

To Reproduce
`import time

from binance import ThreadedWebsocketManager

api_key = '<api_key'>
api_secret = '<api_secret'>

def main():

symbol = 'BNBBTC'

twm = ThreadedWebsocketManager(api_key=api_key, api_secret=api_secret)
# start is required to initialise its internal loop
twm.start()

def handle_socket_message(msg):
    print(f"message type: {msg['e']}")
    print(msg)

twm.start_kline_socket(callback=handle_socket_message, symbol=symbol)

# multiple sockets can be started
twm.start_depth_socket(callback=handle_socket_message, symbol=symbol)

# or a multiplex socket can be started like this
# see Binance docs for stream names
streams = ['bnbbtc@miniTicker', 'bnbbtc@bookTicker']
twm.start_multiplex_socket(callback=handle_socket_message, streams=streams)

twm.join()

if name == "main":
main()`
Expected behavior
A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • Python version: [e.g. 3.5]
  • Virtual Env: [e.g. virtualenv, conda]
  • OS: [e.g. Mac, Ubuntu]
  • python-binance version

Logs or Additional context
Jupyter Lab Python Setup:

  • Python = 3.10.13
  • jupyter lab = 4.0.10
  • python-binance = 1.0.19

PyCharm Setup:

  • Python = 3.9.13
  • python-binance = 1.0.19

Any Ideas on how to fix this? I saw different posts about this from 2022 and 2023 and was wondering if it is still the same fix, replacing some line of code within the python-binance library

Lingua principale
Python
Stelle
7.2k
Fork
2.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sammchardy/python-binance

Tutte le issue di sammchardy/python-binance

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.