MCPcopy
hub / github.com/tornadoweb/tornado / get

Method get

tornado/queues.py:225–254  ·  view source on GitHub ↗

Remove and return an item from the queue. Returns an awaitable which resolves once an item is available, or raises `tornado.util.TimeoutError` after a timeout. ``timeout`` may be a number denoting a time (on the same scale as `tornado.ioloop.IOLoop.time`, normally `

(
        self, timeout: Optional[Union[float, datetime.timedelta]] = None
    )

Source from the content-addressed store, hash-verified

223 self.__put_internal(item)
224
225 def get(
226 self, timeout: Optional[Union[float, datetime.timedelta]] = None
227 ) -> Awaitable[_T]:
228 """Remove and return an item from the queue.
229
230 Returns an awaitable which resolves once an item is available, or raises
231 `tornado.util.TimeoutError` after a timeout.
232
233 ``timeout`` may be a number denoting a time (on the same
234 scale as `tornado.ioloop.IOLoop.time`, normally `time.time`), or a
235 `datetime.timedelta` object for a deadline relative to the
236 current time.
237
238 .. note::
239
240 The ``timeout`` argument of this method differs from that
241 of the standard library's `queue.Queue.get`. That method
242 interprets numeric values as relative timeouts; this one
243 interprets them as absolute deadlines and requires
244 ``timedelta`` objects for relative timeouts (consistent
245 with other timeouts in Tornado).
246
247 """
248 future = Future() # type: Future[_T]
249 try:
250 future.set_result(self.get_nowait())
251 except QueueEmpty:
252 self._getters.append(future)
253 _set_timeout(future, timeout)
254 return future
255
256 def get_nowait(self) -> _T:
257 """Remove and return an item from the queue without blocking.

Callers 15

test_repr_and_strMethod · 0.95
test_maxsizeMethod · 0.95
test_blocking_getMethod · 0.95
test_get_with_puttersMethod · 0.95
test_get_timeoutMethod · 0.95
test_put_with_gettersMethod · 0.95
test_put_timeoutMethod · 0.95

Calls 3

get_nowaitMethod · 0.95
_set_timeoutFunction · 0.85
appendMethod · 0.80

Tested by 15

test_repr_and_strMethod · 0.76
test_maxsizeMethod · 0.76
test_blocking_getMethod · 0.76
test_get_with_puttersMethod · 0.76
test_get_timeoutMethod · 0.76
test_put_with_gettersMethod · 0.76
test_put_timeoutMethod · 0.76