Not able to unsubscribe to tokens in threaded mode

The following error pops up when I try to unsubscribe to all subscribed tokens in threaded=True mode.

Traceback (most recent call last):

File "D:\Anaconda\envs\pyv3916v\lib\site-packages\kiteconnect\", line 601, in unsubscribe
for token in instrument_tokens:

RuntimeError: dictionary changed size during iteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\Meenakshi Sundaram\AppData\Local\Temp\ipykernel_34460\", line 1, in

File "D:\Anaconda\envs\pyv3916v\lib\site-packages\kiteconnect\", line 609, in unsubscribe
self._close(reason="Error while unsubscribe: {}".format(str(e)))

File "D:\Anaconda\envs\pyv3916v\lib\site-packages\kiteconnect\", line 553, in _close, reason)

File "D:\Anaconda\envs\pyv3916v\lib\site-packages\autobahn\websocket\", line 1991, in sendClose
raise Exception("close reason without close code")

Exception: close reason without close code

Connection error: 0 - error parsing request
  • rakeshr
    Connection error: 0 - error parsing request
    You seem to be using the wrong instrument token. You can get all instrument detail from the instruments list.
  • MSTrader
    This document has all the tokens I am trying to subscribe to. Please tell me which token is causing the issue.
  • sujith
    You can check all the instrument tokens from the instruments master.
  • MSTrader
    I think this was probably happening because I did not subscribe to any instrument when i called kws.connect(), and then I was subscribing to all the instruments I wanted. The program worked as expected, and logged all the ticks despite the error.

    Now I am having a new problem, which I have posted in this thread
This discussion has been closed.