MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / get

Method get

lib/sqlalchemy/util/queue.py:171–201  ·  view source on GitHub ↗

Remove and return an item from the queue. If optional args `block` is True and `timeout` is None (the default), block if necessary until an item is available. If `timeout` is a positive number, it blocks at most `timeout` seconds and raises the ``Empty`` exception if

(self, block: bool = True, timeout: Optional[float] = None)

Source from the content-addressed store, hash-verified

169 return self.put(item, False)
170
171 def get(self, block: bool = True, timeout: Optional[float] = None) -> _T:
172 """Remove and return an item from the queue.
173
174 If optional args `block` is True and `timeout` is None (the
175 default), block if necessary until an item is available. If
176 `timeout` is a positive number, it blocks at most `timeout`
177 seconds and raises the ``Empty`` exception if no item was
178 available within that time. Otherwise (`block` is false),
179 return an item if one is immediately available, else raise the
180 ``Empty`` exception (`timeout` is ignored in that case).
181
182 """
183 with self.not_empty:
184 if not block:
185 if self._empty():
186 raise Empty
187 elif timeout is None:
188 while self._empty():
189 self.not_empty.wait()
190 else:
191 if timeout < 0:
192 raise ValueError("'timeout' must be a positive number")
193 endtime = _time() + timeout
194 while self._empty():
195 remaining = endtime - _time()
196 if remaining <= 0.0:
197 raise Empty
198 self.not_empty.wait(remaining)
199 item = self._get()
200 self.not_full.notify()
201 return item
202
203 def get_nowait(self) -> _T:
204 """Remove and return an item from the queue without blocking.

Callers 10

get_nowaitMethod · 0.95
run_plainFunction · 0.95
run_in_processFunction · 0.95
_run_console_scriptMethod · 0.45
became_legacy_20Function · 0.45
importlib_metadata_getFunction · 0.45
get_cls_kwargsFunction · 0.45
__new__Method · 0.45
_warnings_warnFunction · 0.45
getMethod · 0.45

Calls 2

_emptyMethod · 0.95
_getMethod · 0.95

Tested by 2

run_plainFunction · 0.76
run_in_processFunction · 0.76