Get a task from queue for execution.

        Waits `timeout` seconds until a READY task appears in the queue.
        If `timeout` is `None` - waits forever.

        Returns tarantool tuple object.
762520
async def take(self, tube, timeout=None):
        
        cmd = tube.cmd("take")
        args = ()

        if timeout is not None:
            args += (timeout,)

        res = await self.tnt.call(cmd, args)
        return res
805197
def receive(timeout = nil, &block)
      message = nil
      Timers::Wait.for(timeout) do |_remaining|
        message = check(timeout, &block)
        break if message
      end
      return message if message
      raise TaskTimeout, "receive timeout exceeded"
    end
780539
def get_nowait(self):
        
        self._parent._check_closing()
        with self._parent._sync_mutex:
            if self._parent._qsize() == 0:
                raise AsyncQueueEmpty

            item = self._parent._get()
            self._parent._notify_async_not_full(threadsafe=False)
            self._parent._notify_sync_not_full()
            return item
106298
def wait(self, timeout=None):
    
    if self._future:
      try:
        # Future.exception() will return rather than raise any exception so we use it.
        self._future.exception(timeout)
      except concurrent.futures.TimeoutError:
        self._timeout()
      self._refresh_state()
    else:
      # fall back to polling
      while not self.is_complete:
        if timeout is not None:
          if timeout <= 0:
            self._timeout()
          timeout -= Job._POLL_INTERVAL_SECONDS
        time.sleep(Job._POLL_INTERVAL_SECONDS)
    return self
1365669
def respond_via_request(self, task):
        
        warn(f"Detected slow response into webhook. "
             f"(Greater than {RESPONSE_TIMEOUT} seconds)\n"
             f"Recommended to use 'async_task' decorator from Dispatcher for handler with long timeouts.",
             TimeoutWarning)

        dispatcher = self.get_dispatcher()
        loop = dispatcher.loop

        try:
            results = task.result()
        except Exception as e:
            loop.create_task(
                dispatcher.errors_handlers.notify(dispatcher, types.Update.get_current(), e))
        else:
            response = self.get_response(results)
            if response is not None:
                asyncio.ensure_future(response.execute_response(dispatcher.bot), loop=loop)
919501
def result(self, timeout=None):
        
        if not self._done.wait(timeout):
            raise Timeout('timeout waiting for future')
        # No more state changes after _done is set so no lock needed.
        if self._state == self.S_EXCEPTION:
            raise compat.saved_exc(self._result)
        return self._result
673348
def get(self, block=True, timeout=None):
        """"""
        return self._queue.get(block, timeout)
699778
def wait(self, timeout=-1):
        
        if self._process is None:
            raise RuntimeError('no child process')
        if timeout == -1:
            timeout = self._timeout
        if not self._child_exited.wait(timeout):
            raise Timeout('timeout waiting for child to exit')
        return self.returncode
487376
def wait_until(timeout=10)
      time_to_stop = Time.now + timeout
      while true
        rval = yield
        return rval if rval
        raise TimeoutError, "timeout of #{timeout}s exceeded" if Time.now > time_to_stop
        Thread.pass
      end
    end
643008
def get(self, timeout=None):
        
        if not self.wait(timeout):
            raise TimeoutError("Result not available within %fs" % timeout)
        if self._success:
            return self._data
        raise self._data[0]
1212520
def wait(self, timeout=None):
    

    tbegin = _get_timeout_begin(timeout)
    with self._lock:
      while self._queue or self._running:
        remainder = _get_timeout_remainder(tbegin, timeout)
        if remainder is not None and remainder <= 0.0:
          return False  # timeout
        self._lock.wait(remainder)
      if self._shutdown:
        for worker in self._workers:
          worker.join()
    return True
682436
def get(self, timeout):
        

        # At first get we return a ping so the client immediately receives data
        if self._first:
            self._first = False
            return ("ping", PingStats.get(), {})

        try:
            (action, msg, kwargs) = yield from asyncio.wait_for(super().get(), timeout)
        except asyncio.futures.TimeoutError:
            return ("ping", PingStats.get(), {})
        return (action, msg, kwargs)
1211291
public <T> T callWithTimeout(String description, int timeout, Callable<T> task) {
        Future<T> callFuture = threadPool.submit(task);
        return getWithTimeout(callFuture, timeout, description);
    }
1249184
def get_nowait(self) -> _T:
        
        self._consume_expired()
        if self._putters:
            assert self.full(), "queue not full, why are putters waiting?"
            item, putter = self._putters.popleft()
            self.__put_internal(item)
            future_set_result_unless_cancelled(putter, None)
            return self._get()
        elif self.qsize():
            return self._get()
        else:
            raise QueueEmpty
419343
def task(self, _fn=None, queue=None, hard_timeout=None, unique=None,
             lock=None, lock_key=None, retry=None, retry_on=None,
             retry_method=None, schedule=None, batch=False,
             max_queue_size=None):
        

        def _delay(func):
            def _delay_inner(*args, **kwargs):
                return self.delay(func, args=args, kwargs=kwargs)
            return _delay_inner

        # Periodic tasks are unique.
        if schedule is not None:
            unique = True

        def _wrap(func):
            if hard_timeout is not None:
                func._task_hard_timeout = hard_timeout
            if queue is not None:
                func._task_queue = queue
            if unique is not None:
                func._task_unique = unique
            if lock is not None:
                func._task_lock = lock
            if lock_key is not None:
                func._task_lock_key = lock_key
            if retry is not None:
                func._task_retry = retry
            if retry_on is not None:
                func._task_retry_on = retry_on
            if retry_method is not None:
                func._task_retry_method = retry_method
            if batch is not None:
                func._task_batch = batch
            if schedule is not None:
                func._task_schedule = schedule
            if max_queue_size is not None:
                func._task_max_queue_size = max_queue_size

            func.delay = _delay(func)

            if schedule is not None:
                serialized_func = serialize_func_name(func)
                assert serialized_func not in self.periodic_task_funcs, \
                    "attempted duplicate registration of periodic task"
                self.periodic_task_funcs[serialized_func] = func

            return func

        return _wrap if _fn is None else _wrap(_fn)
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
532849
def wait(self, timeout=None):
        
        self.ev_done.wait(timeout=timeout)

        if not self.ev_done.is_set():
            raise TaskTimeout("Task %s timed out." % self)

        # --> self.result is set
        # If it is an exception, then raise it in this waiter
        if isinstance(self.result, Exception):
            raise self.result

        # Release waiters and perform callbacks
        # done() has already been called, because of self.ev_done check
        # "asynchronous" tasks should could call done() here
        #self.done(self.result)

        return self.result