def getq(self):
    if self._queue:
      fut = self._queue.popleft()
      # TODO: Isn't it better to call self.set_result(None) in complete()?
      if not self._queue and self._full or not self._done:
        self.set_result(None)
    else:
      fut = Future()
      if self._full:
        if not self._done:
          raise RuntimeError('self._queue should be non-empty.')
        err = self.get_exception()
        if err is not None:
          tb = self.get_traceback()
        else:
          err = EOFError('Queue is empty')
          tb = None
        fut.set_exception(err, tb)
      else:
        self._waiting.append(fut)
    return fut
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/ext/ndb/tasklets.py/SerialQueueFuture.getq/operator `and` -> `or`