MCPcopy Index your code
hub / github.com/python/cpython / get

Method get

Lib/asyncio/queues.py:172–201  ·  view source on GitHub ↗

Remove and return an item from the queue. If queue is empty, wait until an item is available. Raises QueueShutDown if the queue has been shut down and is empty, or if the queue has been shut down immediately.

(self)

Source from the content-addressed store, hash-verified

170 self._wakeup_next(self._getters)
171
172 async def get(self):
173 """Remove and return an item from the queue.
174
175 If queue is empty, wait until an item is available.
176
177 Raises QueueShutDown if the queue has been shut down and is empty, or
178 if the queue has been shut down immediately.
179 """
180 while self.empty():
181 if self._is_shutdown and self.empty():
182 raise QueueShutDown
183 getter = self._get_loop().create_future()
184 self._getters.append(getter)
185 try:
186 await getter
187 except:
188 getter.cancel() # Just in case getter is not done yet.
189 try:
190 # Clean self._getters from canceled getters.
191 self._getters.remove(getter)
192 except ValueError:
193 # The getter could be removed from self._getters by a
194 # previous put_nowait call, or a shutdown call.
195 pass
196 if not self.empty() and not getter.cancelled():
197 # We were woken up by put_nowait(), but can't take
198 # the call. Wake up the next in line.
199 self._wakeup_next(self._getters)
200 raise
201 return self.get_nowait()
202
203 def get_nowait(self):
204 """Remove and return an item from the queue.

Callers 15

test_enter_concurrentMethod · 0.95
test_args_argumentMethod · 0.95
test_processMethod · 0.95
test_lose_target_refMethod · 0.95
test_getMethod · 0.95
test_forkMethod · 0.95
test_qsizeMethod · 0.95
test_wait_returnMethod · 0.95

Calls 9

emptyMethod · 0.95
_wakeup_nextMethod · 0.95
get_nowaitMethod · 0.95
_get_loopMethod · 0.80
create_futureMethod · 0.45
appendMethod · 0.45
cancelMethod · 0.45
removeMethod · 0.45
cancelledMethod · 0.45

Tested by 15

test_enter_concurrentMethod · 0.76
test_args_argumentMethod · 0.76
test_processMethod · 0.76
test_lose_target_refMethod · 0.76
test_getMethod · 0.76
test_forkMethod · 0.76
test_qsizeMethod · 0.76
test_wait_returnMethod · 0.76