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