MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / get

Method get

tools/python-3.11.9-amd64/Lib/queue.py:154–183  ·  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 non-negative number, it blocks at most 'timeout' seconds and raises the Empty excepti

(self, block=True, timeout=None)

Source from the content-addressed store, hash-verified

152 self.not_empty.notify()
153
154 def get(self, block=True, timeout=None):
155 '''Remove and return an item from the queue.
156
157 If optional args 'block' is true and 'timeout' is None (the default),
158 block if necessary until an item is available. If 'timeout' is
159 a non-negative number, it blocks at most 'timeout' seconds and raises
160 the Empty exception if no item was available within that time.
161 Otherwise ('block' is false), return an item if one is immediately
162 available, else raise the Empty exception ('timeout' is ignored
163 in that case).
164 '''
165 with self.not_empty:
166 if not block:
167 if not self._qsize():
168 raise Empty
169 elif timeout is None:
170 while not self._qsize():
171 self.not_empty.wait()
172 elif timeout < 0:
173 raise ValueError("'timeout' must be a non-negative number")
174 else:
175 endtime = time() + timeout
176 while not self._qsize():
177 remaining = endtime - time()
178 if remaining <= 0.0:
179 raise Empty
180 self.not_empty.wait(remaining)
181 item = self._get()
182 self.not_full.notify()
183 return item
184
185 def put_nowait(self, item):
186 ''&#x27;Put an item into the queue without blocking.

Callers 15

get_nowaitMethod · 0.95
selectMethod · 0.45
_append_untaggedMethod · 0.45
_check_byeMethod · 0.45
_find_implFunction · 0.45
__get__Method · 0.45
_strptimeFunction · 0.45
visit_ConstantMethod · 0.45
__instancecheck__Method · 0.45
get_precedenceMethod · 0.45
get_type_commentMethod · 0.45
__call__Method · 0.45

Calls 5

_qsizeMethod · 0.95
_getMethod · 0.95
timeClass · 0.90
waitMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected