pykiteconnect icon indicating copy to clipboard operation
pykiteconnect copied to clipboard

Allow an option for passing "installSignalHandlers" to reactor.run when threaded is set to False in the KiteTicker connect() function

Open h-vishal opened this issue 7 years ago • 1 comments

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.

h-vishal avatar Apr 20 '18 12:04 h-vishal

This is very nice idea. I hope this get PRed in the main repo. nice idea @h-vishal

hemangjoshi37a avatar Feb 14 '23 13:02 hemangjoshi37a