'how can match the list variable from websocket to connected other function? (websocket speed fast)

Python 3.8. purpose: crypto bot

I am inventing my trade bot - purchase order based on realtime data from websocket.

the variable from websocket receiving to purchase order.

Variable : Coin name, current price, volume

However, I found that there is wrongly arranged coinname and price because too fast data coming from websocket. see below e.g result in terminal

[websocket data] KRW-ETC 37910.0 3929084208.6026936
[websocket data] KRW-KAVA 6425.0 15130964966.364386
[Purchase variable] KRW-ETC, 6425.0 this information is being a base coming from websocket to place an order.
[websocket data] KRW-VET 62.9 5068532801.084056

KRW-ETC is a list with 37910.0 (price) as variable for Purchase function and next websocket data(list variable) is KRW-KAVA with 6425. after it, Purchase function gets variable - KRW-ETC + 6425.0 (which is KRW-KAVA price, next data from websocket).

anybody who knows how to manage this - well-paired with purchase function/fast websocket data speed, please kindly advise me.

in websocket receiving function

while True : 
        data = wm.get()
        self.code, self.close, self.volume = data['code'], data['trade_price'], data['acc_trade_price']
        print(self.code, self.close , self.volume)
        self.__q.put([self.code, self.close, self.volume])

Purchase order

def purchase(self):
    while True: 
        print(f'{self.__q.get()[0]}, {self.__q.get()[1]} this information is being a base coming from websocket to place an order. ') 


Solution 1:[1]

I found a solution by myself. Just to pick self.__q data as another variable and use the variable. E.g)

Value = self__q.get()

Then I can use the value in the function freely without change. This happened because while I use self__q, self__q value is changed by web-socket to download another data.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Freddy Mcloughlan