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

Method put

tornado/queues.py:186–207  ·  view source on GitHub ↗

Put an item into the queue, perhaps waiting until there is room. Returns a Future, which 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 `time.time`), or a

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

Source from the content-addressed store, hash-verified

184 return self.qsize() >= self.maxsize
185
186 def put(
187 self, item: _T, timeout: Optional[Union[float, datetime.timedelta]] = None
188 ) -> "Future[None]":
189 """Put an item into the queue, perhaps waiting until there is room.
190
191 Returns a Future, which raises `tornado.util.TimeoutError` after a
192 timeout.
193
194 ``timeout`` may be a number denoting a time (on the same
195 scale as `tornado.ioloop.IOLoop.time`, normally `time.time`), or a
196 `datetime.timedelta` object for a deadline relative to the
197 current time.
198 """
199 future = Future() # type: Future[None]
200 try:
201 self.put_nowait(item)
202 except QueueFull:
203 self._putters.append((item, future))
204 _set_timeout(future, timeout)
205 else:
206 future.set_result(None)
207 return future
208
209 def put_nowait(self, item: _T) -> None:
210 """Put an item into the queue without blocking.

Callers 15

test_repr_and_strMethod · 0.95
test_maxsizeMethod · 0.95
test_get_with_puttersMethod · 0.95
test_async_forMethod · 0.95
test_blocking_putMethod · 0.95
test_put_with_gettersMethod · 0.95
test_put_timeoutMethod · 0.95

Calls 3

put_nowaitMethod · 0.95
_set_timeoutFunction · 0.85
appendMethod · 0.80

Tested by 15

test_repr_and_strMethod · 0.76
test_maxsizeMethod · 0.76
test_get_with_puttersMethod · 0.76
test_async_forMethod · 0.76
test_blocking_putMethod · 0.76
test_put_with_gettersMethod · 0.76
test_put_timeoutMethod · 0.76