def _replay_transaction_log(self, debug = False):
        self._open_log()
        bytes_read = 0
        logging.debug("Reading back transaction log for %s" % self.queue_name)
    
        while True:
            cmd = self.transaction_log.read(1)
            if not cmd:
                break;
            if cmd == TRX_CMD_PUSH:
                raw_size = self.transaction_log.read(4)
                size = unpack("I", raw_size)
                data = self.transaction_log.read(size[0])
                if not data:
                    continue
                self.put(data, False)
                bytes_read += len(data)
            elif cmd == TRX_CMD_POP:
                bytes_read -= len(self.get(False))
            else:
                logging.warning("Error reading transaction log: I don't understand '%s' (skipping)." % cmd)
        logging.debug("Reading back transaction log is done.")
        return bytes_read
dataset/ETHPy150Open cyberdelia/peafowl/peafowl/queue.py/PersistentQueue._replay_transaction_log/original