pykiteconnect
pykiteconnect copied to clipboard
Allow an option for passing "installSignalHandlers" to reactor.run when threaded is set to False in the KiteTicker connect() function
We have a class that manages the ticker thread, with the switch to 3.0 we can't use the KiteTicker class directly because we are not running it in the main thread, and we can't use the threaded option in connect() because this creates a new thread in our ticker thread, which is suppose to block on the connect function.
This is the relevant snippet from the current version of the connect() function -
# Run in seperate thread of blocking
opts = {}
if threaded:
# Signals are not allowed in non main thread by twisted so supress it.
opts["installSignalHandlers"] = False
self.websocket_thread = threading.Thread(target=reactor.run, kwargs=opts)
self.websocket_thread.daemon = True
self.websocket_thread.start()
else:
reactor.run(**opts)
Ideally we would like an input flag on the connect function to be able to set the "installSignalHandlers" in the else clause in the above snippet.
This is very nice idea. I hope this get PRed in the main repo. nice idea @h-vishal