@retry_on(zookeeper.BadVersionException)
    def _move(self, src, dest):
        try:
            (data, stat) = self._zk.get(src, None)
            if data:
                # create a temporary optimistic lock by forcing a version increase
                self._zk.set(src, data, stat['version'])
                self._zk.set(dest, data)
                self._zk.delete(src, stat['version'] + 1)
                return data

            elif stat['ctime'] < 1000*(300 - time.time()): # 5 minutes. stat['ctime'] is in milliseconds since epoch.
                # a producer failed to enqueue an element
                # the consumer should just drop the empty item
                try:
                    self._zk.delete(src)
                except zookeeper.NoNodeException:
                    pass # someone else already removed the node

                return None

        except zookeeper.NoNodeException:
            # a consumer already reserved this znode
            self._zk.set(dest, '')
            return None
dataset/ETHPy150Open andreisavu/zookeeper-mq/zkmq.py/Consumer._move/swapped operands of `-`