twelvedata / twelvedata-python

Twelve Data Python Client - Financial data API & WebSocket
https://twelvedata.com
MIT License
392 stars 57 forks source link

[Question]websocket.TDWebSocket.keep_alive() high cpu usage #20

Closed willhess92 closed 4 years ago

willhess92 commented 4 years ago

websocket.TDWebSocket.keep_alive() is simply an infinite loop, which I've assumed is to keep the main thread alive and results in high cpu usage. Does having a time.sleep() in here affect the performance of the websocket connection? I personally wouldn't think so, but I'm testing while the market is closed.

@staticmethod def keep_alive(): while True: pass

Thanks

midasSSS commented 4 years ago

Fixed high CPU usage in 65cc731. Also added heartbeat events sent every 10 seconds to the WebSocket server in order to avoid connection closing.