def _resample_ticker(self, prod_code):
    tickers = []
    q = self._ticker_queues[prod_code]
    code = self.prod_codes[prod_code]
    time_diff = 0
    while True:
        try:
            tick = q.get(timeout=1)
            time_diff = (tick['TickerTime'] - time.time())
            print(time_diff)
        except Empty:
            if (tickers and ((time.time() % (tickers[(- 1)]['TickerTime'] // 60)) >= (61 + time_diff))):
                price_list = []
                vol_list = []
                d = dt.datetime.fromtimestamp(tickers[(- 1)]['TickerTime']).replace(second=0)
                for t in tickers:
                    price_list.append(t['Price'])
                    vol_list.append(t['Qty'])
                (o, h, l, c, v) = (price_list[0], max(price_list), min(price_list), price_list[(- 1)], sum(vol_list))
                self._col.update_one({'datetime': d, 'code': code}, {'$set': {'datetime': d, 'code': code, 'open': o, 'high': h, 'low': l, 'close': c, 'volume': v, 'trade_date': self.trade_date}}, upsert=True)
                self._trigger_queue.put(d)
                tickers.clear()
            continue
        if (tick is None):
            break
        if (tickers and ((tickers[(- 1)]['TickerTime'] // 60) != (tick['TickerTime'] // 60))):
            price_list = []
            vol_list = []
            d = dt.datetime.fromtimestamp(tickers[(- 1)]['TickerTime']).replace(second=0)
            for t in tickers:
                price_list.append(t['Price'])
                vol_list.append(t['Qty'])
            (o, h, l, c, v) = (price_list[0], max(price_list), min(price_list), price_list[(- 1)], sum(vol_list))
            self._col.update_one({'datetime': d, 'code': code}, {'$set': {'datetime': d, 'code': code, 'open': o, 'high': h, 'low': l, 'close': c, 'volume': v, 'trade_date': self.trade_date}}, upsert=True)
            self._trigger_queue.put(d)
            tickers.clear()
        tickers.append(tick)
def _resample_ticker(self, prod_code):
    tickers = []
    q = self._ticker_queues[prod_code]
    code = self.prod_codes[prod_code]
    time_diff = 0
    while True:
        try:
            tick = q.get(timeout=1)
            time_diff = (tick['TickerTime'] - time.time())
            print(time_diff)
        except Empty:
            if (tickers and ((time.time() % (tickers[(- 1)]['TickerTime'] // 60)) >= (61 + time_diff))):
                price_list = []
                vol_list = []
                d = dt.datetime.fromtimestamp(tickers[(- 1)]['TickerTime']).replace(second=0)
                for t in tickers:
                    price_list.append(t['Price'])
                    vol_list.append(t['Qty'])
                (o, h, l, c, v) = (price_list[0], max(price_list), min(price_list), price_list[(- 1)], sum(vol_list))
                self._col.update_one({'datetime': d, 'code': code}, {'$set': {'datetime': d, 'code': code, 'open': o, 'high': h, 'low': l, 'close': c, 'volume': v, 'trade_date': self.trade_date}}, upsert=True)
                self._trigger_queue.put(d)
                tickers.clear()
            continue
        if (tick is None):
            break
        if (tickers and ((tickers[(- 1)]['TickerTime'] // 60) != (tick['TickerTime'] // 60))):
            price_list = []
            vol_list = []
            d = dt.datetime.fromtimestamp(tickers[(- 1)]['TickerTime']).replace(second=0)
            for t in tickers:
                price_list.append(t['Price'])
                vol_list.append(t['Qty'])
            (o, h, l, c, v) = (price_list[0], max(price_list), min(price_list), price_list[(- 1)], sum(vol_list))
            self._col.update_one({'datetime': d, 'code': code}, {'$set': {'datetime': d, 'code': code, 'open': o, 'high': h, 'low': l, 'close': c, 'volume': v, 'trade_date': self.trade_date}}, upsert=True)
            self._trigger_queue.put(d)
            tickers.clear()
        tickers.append(tick)