Websocket: Stop ws.run_forever after 15 minutes
Hi I'm working on this Finnhub api where I get the details of the selected stocks. As i give ws.run_forever(), it is not stopping. But i wanna run it for 15 mins and then stop. Also keep_running= False is not working for me. Any idea guys? import websocket def on_message(ws, message): print(message) def on_error(ws, error): print(error) def on_close(ws): print("### closed ###") def on_open(ws): ws.send('{"type":"subscribe","symbol":"AAPL"}') ws.send('{"type":"subscribe","symbol":"AMZN"}') ws.send('{"type":"subscribe","symbol":"BINANCE:BTCUSDT"}') ws.send('{"type":"subscribe","symbol":"IC MARKETS:1"}') if name == "main": websocket.enableTrace(True) ws = websocket.WebSocketApp("wss://ws.finnhub.io?token=", on_message = on_message, on_error = on_error, on_close = on_close) ws.on_open = on_open ws.run_forever()