LUCIT-Systems-and-Development / unicorn-binance-websocket-api

A Python SDK by LUCIT to use the Binance Websocket API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, com-coin_futures, us, tr, dex/chain+testnet) in a simple, fast, flexible, robust and fully-featured way.
https://unicorn-binance-websocket-api.docs.lucit.tech/
Other
680 stars 165 forks source link

Unable to start Unicorn Binance Websocket Api CRITICAL:root:BinanceWebSocketApiManager._create_stream_thread() #145

Closed bashman closed 3 years ago

bashman commented 3 years ago

Greetings.

I'm getting this error:

CRITICAL:root:BinanceWebSocketApiManager._create_stream_thread() stream_id=d22cb27d-04f1-41c2-a100-4ecab6062091 error: 7 - can't register atexit after shutdown

Possible reason: Python 3.9

I am running Unicorn Binance Websocket Api in other computer and this runs very well, and fast but python versión is python 3.8

oliver-zehentleitner commented 3 years ago

Just to link the python3.9 issues: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/issues/131

oliver-zehentleitner commented 3 years ago

Hi Bashman, could you provide more infos, just to get a picture of this problem? How often does this happen? What happens then? Is the lib down or do the streams reconnect?

bashman commented 3 years ago

Hi Bashman, could you provide more infos, just to get a picture of this problem? How often does this happen? What happens then? Is the lib down or do the streams reconnect?

Hi. Oliver, no, is only this message. UBWSA, don't works before...

xilopaint commented 3 years ago

Using Python 3.9 the issue can be reproduced just like this:

from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager

API_KEY = '*'
API_SECRET = '*'

binance_websocket_api_manager = BinanceWebSocketApiManager(
    exchange='binance.com-futures',
)

binance_websocket_api_manager.create_stream(
    channels=['!userData'],
    markets=['arr'],
    api_key=API_KEY,
    api_secret=API_SECRET
)
$ ./sample.py
CRITICAL:root:BinanceWebSocketApiManager._create_stream_thread() stream_id=623d563a-88fb-4304-9ffe-94549e463825  - RuntimeError error_msg:  - cannot schedule new futures after interpreter shutdown - stopping and shutting down - read https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/issues/131 for further information!
oliver-zehentleitner commented 3 years ago

This is a different error as mentioned in the first post, but it seems to be related to python3.9: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/issues/131

xilopaint commented 3 years ago

This is a different error as mentioned in the first post, but it seems to be related to python3.9:

131

Oh, I didn't realize it was a different error. Any idea about the fix for #131 or it's a bug in Python 3.9?

oliver-zehentleitner commented 3 years ago

All I know is: "cannot schedule new futures after interpreter shutdown"

If someone finds a reason why the interpreter is down, we can try to fix that. But this error is to generic. And it only happens with 3.9 so far.

I will close this. Anyone can reopen with new infos!

TBMoonwalker commented 2 years ago

The python-telegram-bot had the same problem with Python 3.9 - maybe you can find the fix there.

oliver-zehentleitner commented 2 years ago

thanks, buts its solved :)

oliver-zehentleitner commented 2 years ago

https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api/issues/131

TBMoonwalker commented 2 years ago

No, it isn't. Tested it with latest Python 3.9 docker image on a Raspberry PI 4 (4GB) in a Kubernetes environment. Exactly the same image with the latest Python version 3.8 is running fine. If it works for you now - maybe there is a timing problem on "slower" machines?

oliver-zehentleitner commented 2 years ago

Which UBWA Version do you use? I am sure the issue is fixed on reproducable systems.

I fixed it last week.... so you must use the latest version and high_performance must not be True!

If still persists, please open a new issue with logfiles and the error msg. Is it realy thrown from the same code as before?

I need a way to reproduce the error.

oliver-zehentleitner commented 2 years ago

It definitly was a timing problem. Since my update the code blocks till thread AND coroutine loop of the new stream are ready started which avoids the error in our tests.