Remove and get the last element in a list, or block until one
        is available.

        :raises TypeError: if timeout is not int
        :raises ValueError: if timeout is less than 0
767285
def brpop(self, key, *keys, timeout=0, encoding=_NOTSET):
        
        if not isinstance(timeout, int):
            raise TypeError("timeout argument must be int")
        if timeout < 0:
            raise ValueError("timeout must be greater equal 0")
        args = keys + (timeout,)
        return self.execute(b'BRPOP', key, *args, encoding=encoding)
1222277
def timeout(self, timeout):
        
        clone = copy.deepcopy(self)
        clone._timeout = timeout
        return clone
137264
def last(self, name, value):
        
        counter = self.get(name, CounterType.LastValue)
        counter.last = value
        self._update()
1124359
def value(self):
        
        try:
            value = self.lastValue
        except IndexError:
            value = "NaN"
        except ValueError:
            value = "NaN"
        return value
109041
def __get_new_timeout(self, timeout):
        
        try:
            timeout_multiplier = float(self.timeout_multiplier)
            if timeout_multiplier <= 0.5:
                timeout_multiplier = 0.5
            timeout = int(math.ceil(timeout_multiplier * timeout))
            return timeout
        except Exception:
            # Wrong data type for timeout_multiplier (expecting int or float)
            return timeout
156125
def grab_next(self, timeout: float=None) -> typing.List[DataAndMetadata.DataAndMetadata]:
        """"""
        with self.__buffer_lock:
            self.__buffer = list()
        return self.grab_latest(timeout)
1232106
def wait_gone(self, timeout=None, raise_error=True):
        
        start_time = time.time()
        if timeout is None or timeout <= 0:
            timeout = self.timeout
        while start_time + timeout > time.time():
            if not self.exists:
                return True
        if not raise_error:
            return False
        raise WDAElementNotDisappearError("element not gone")
1211615
async def wait_until_ready(
        self, timeout: Optional[float] = None, no_raise: bool = False
    ) -> bool:
        
        if self.node.ready.is_set():
            return True

        try:
            return await self.node.wait_until_ready(timeout=timeout)
        except asyncio.TimeoutError:
            if no_raise:
                return False
            else:
                raise
140682
def _get_timeout(self, timeout):
        '''
        
        '''
        if timeout is None:
            return self.opts['timeout']
        if isinstance(timeout, int):
            return timeout
        if isinstance(timeout, six.string_types):
            try:
                return int(timeout)
            except ValueError:
                return self.opts['timeout']
        # Looks like the timeout is invalid, use config
        return self.opts['timeout']
177774
def _pop(self, block=True, timeout=None, left=False):
        
        item  = None
        timer = None
        deque = self._deque
        empty = IndexError('pop from an empty deque')

        if block is False:
            if len(self._deque) > 0:
                item = deque.popleft() if left else deque.pop()
            else:
                raise empty
        else:
            try:
                if timeout is not None:
                    timer = gevent.Timeout(timeout, empty)
                    timer.start()

                while True:
                    self.notEmpty.wait()
                    if len(deque) > 0:
                        item = deque.popleft() if left else deque.pop()
                        break
            finally:
                if timer is not None:
                    timer.cancel()

        if len(deque) == 0:
            self.notEmpty.clear()

        return item
180494
def last(self):
        """"""
        if len(self._range) == 0:
            raise IndexError("range is empty")
        if self._idx == -1:
            return self._range[0]
        return self._get(self._idx)
580401
def PopItem(self):
    
    try:
      # If no timeout is specified the queue will block if empty otherwise
      # a Queue.Empty exception is raised.
      return self._queue.get(timeout=self._timeout)

    except KeyboardInterrupt:
      raise errors.QueueClose

    # If close() is called on the multiprocessing.Queue while it is blocking
    # on get() it will raise IOError.
    except IOError:
      raise errors.QueueClose

    except Queue.Empty:
      raise errors.QueueEmpty
490196
def poll(self, timeout):
        
        now = time.time()
        end_time = now + float(timeout)
        prev_timeout = self.stream.gettimeout()
        self.stream.settimeout(self._poll_period)
        incoming = None
        try:
            while (end_time - now) >= 0:
                try:
                    incoming = self.stream.recv(self._max_read)
                except socket.timeout:
                    pass
                if incoming:
                    return incoming
                now = time.time()
            raise ExpectTimeout()
        finally:
            self.stream.settimeout(prev_timeout)
629868
def join(self, timeout=None):
        
        rv = self.thread.join(timeout)
        if self.err:
            raise self.err
        return self.val
406939
def get(self, timeout=None):
        # type: (float) -> T
        """"""
        self.wait(timeout)
        if isinstance(self._result, Exception):
            raise self._result
        return self._result
75188
def settimeout(self, timeout):
        '''
        
        '''
        if timeout is None:
            self._block = True
        elif float(timeout) == 0.0:
            self._block = False
        else:
            self._timeout = float(timeout)
            self._block = True
662339
def timeout(self, timeout):
        

        if timeout is None:
            self._timeout = None  # no timeout
            return
        self._timeout = float(timeout)