Hi, I was trying to implement a web app using the ticker information. However I am using it as a just a function it all works fine but when I try to run the flask application, it throws the below error. Can anyone help me on how to handle the subscription of tick data in the web app. Appreciate the help.
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler)) builtins.ValueError: signal only works in main thread
i tried the solutions mentioned in the stackoverflow thread, but none worked for me. An example would really help if you have. i even tried socketio.run(app) - it runs the app but doesn't load the webpage.
Just see what Kite is doing internally, Kite allows to running ticker in threaded mode internally by using connect(threaded=True).
If you look at connect code, if threaded: # Signals are not allowed in non main thread by twisted so suppress it. opts["installSignalHandlers"] = False self.websocket_thread = threading.Thread(target=reactor.run, kwargs=opts) self.websocket_thread.daemon = True self.websocket_thread.start()
An example would really help if you have. i even tried socketio.run(app) - it runs the app but doesn't load the webpage.
@pssantosh did you solve this finally?
Kite allows to running ticker in threaded mode internally by using connect(threaded=True).
If you look at connect code,
if threaded:
# Signals are not allowed in non main thread by twisted so suppress it.
opts["installSignalHandlers"] = False
self.websocket_thread = threading.Thread(target=reactor.run, kwargs=opts)
self.websocket_thread.daemon = True
self.websocket_thread.start()
You can do the same!