Websocket Keyboard interrupt handling.

ansumanm
Hi,

What is the proper way to handle keyboard interrupt in websocket?

I am handling the interrupt like this but it gives and expection:-

# Infinite loop on the main thread. Nothing after this will run.
# You have to use the pre-defined callbacks to manage subscriptions.

try:
kws.connect()
except KeyboardInterrupt:
print("Exiting on demand..")
finally:
kws.close()


^CERROR:kiteconnect.ticker:WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost.
].

Thanks,
Ansuman
  • sujith
    @ansumanm,
    Can you log inside finally block and check if it is being called or not?
  • ansumanm
    Yes.."finally" block gets executed. One more issue I am seeing is even after market times are over, I am getting ticks for NSE instruments like Nifty Bank and Nifty 50. This is Kite3.
Sign In or Register to comment.