Hattorius / Tradingview-ticker

Reverse engineered connection to the TradingView ticker in Python
GNU General Public License v3.0
47 stars 17 forks source link

Program freezing at websockets.connect() #1

Closed Hattorius closed 3 years ago

Hattorius commented 3 years ago

Expected Behavior

The program should send authorization messages after which it'll receive updates on the tickers

Current Behavior

Freezes on websockets.connect(), continues the program but freezes eventually when the program tries to send a message https://github.com/Hattorius/Tradingview-ticker/blob/ed2131e958f86baf2aa655f25264fee91d9241d9/start.py#L14-L20

Steps to Reproduce

The following code should give you the same issue:

tick = ticker()
tick.start()
Hattorius commented 3 years ago

For some dark and unknown reasons it actually starts when you open 50 connections:

for i in range(50):
    print(i+1)
    tick = ticker()
    tick.start()

It doesn't work if you don't include the print(i+1)

Hattorius commented 3 years ago

Since https://github.com/Hattorius/Tradingview-ticker/commit/be09b070aec8e7b5f8bf1d746849fe014211fffb it'll need 51 connections instead of 50?

for i in range(51):
    print(i+1)
    tick = ticker()
    tick.start()

This is spooky man :(

Antony1060 commented 3 years ago

👻 Computers are spooky

GnarLito commented 3 years ago

appears to be an issue with closing the threads before they're fully started, this is only a problem when 1 instance is created.

To fix this issue add a sleep function to the end of the file.

time.sleep(1)

This will make sure all threads are fully running before closing the main thread.