How to manage method cycle of Websocket?

Hi there,

Would be thankful if someone elaborate the the method cycle of websocket..

my purpose is to get a list of working symbols that doesn't have 's'=='error' status, and then put that list to websocket subscribe method.. 

like suppose in case i have two scenarios..

  • list of symbols say =>  ['MCX:GOLDM22OCTFUT', 'MCX:COTTON22OCTFUT', 'MCX:GOLDGUINEA22SEPFUT', 'MCX:GOLDM22OCTFUT', 'MCX:GOLDPETAL22SEPFUT', 'MCX:KAPAS22NOVFUT']
  • single symbol say =>  [“NSE:SBIN-EQ”]

 now what happens that if we go through first scenario, that we do subscribe to a list of multiple symbols, and if first symbol has 's'='error' or 'no data' rest of the symbols are not getting streamed and updated...

now if we use "if else" validation on the received response 's' != 'error' and want to remove that symbol and also unsubscribe that symbol from that particular subscription main list, the function does not work as i tried to do so..

sample code that i tried is as given below..

def getWrkList(symls):
    global fyersSocket, data_type
    erL = []
    wrL = []
    for smb in symls:
        print("smb => \n",smb)
        time.sleep(0.5)
        if smb not in erL:
            fyersSocket.subscribe(symbol=[smb], data_type=data_type)
            # print(fyersSocket.response)
            if fyersSocket.response['s'] == 'error':
                erL.append(smb)
                print("erl sym=> \n", smb)
                fyersSocket.unsubscribe(symbol=[smb])
            else:
                wrL.append(smb)
                print("wrl sym1=> \n", smb)
                fyersSocket.unsubscribe(symbol=[smb])
        else:
            fyersSocket.unsubscribe(symbol=[smb])
    print("erL => \n",erL)
    print("wrL => \n",wrL)
    return wrL