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

Method shutdown

Lib/asyncio/queues.py:250–278  ·  view source on GitHub ↗

Shut-down the queue, making queue gets and puts raise QueueShutDown. By default, gets will only raise once the queue is empty. Set 'immediate' to True to make gets raise immediately instead. All blocked callers of put() and get() will be unblocked. If 'immediate',

(self, immediate=False)

Source from the content-addressed store, hash-verified

248 await self._finished.wait()
249
250 def shutdown(self, immediate=False):
251 """Shut-down the queue, making queue gets and puts raise QueueShutDown.
252
253 By default, gets will only raise once the queue is empty. Set
254 'immediate' to True to make gets raise immediately instead.
255
256 All blocked callers of put() and get() will be unblocked.
257
258 If 'immediate', the queue is drained and unfinished tasks
259 is reduced by the number of drained tasks. If unfinished tasks
260 is reduced to zero, callers of Queue.join are unblocked.
261 """
262 self._is_shutdown = True
263 if immediate:
264 while not self.empty():
265 self._get()
266 if self._unfinished_tasks > 0:
267 self._unfinished_tasks -= 1
268 if self._unfinished_tasks == 0:
269 self._finished.set()
270 # All getters need to re-check queue-empty to raise ShutDown
271 while self._getters:
272 getter = self._getters.popleft()
273 if not getter.done():
274 getter.set_result(None)
275 while self._putters:
276 putter = self._putters.popleft()
277 if not putter.done():
278 putter.set_result(None)
279
280
281class PriorityQueue(Queue):

Callers 10

_write_sendmsgMethod · 0.45
_write_sendMethod · 0.45
write_eofMethod · 0.45
_call_connection_lostMethod · 0.45
_loop_writingMethod · 0.45
write_eofMethod · 0.45
_do_shutdownMethod · 0.45
closeMethod · 0.45
_clearExistingHandlersFunction · 0.45

Calls 5

emptyMethod · 0.95
_getMethod · 0.95
setMethod · 0.45
doneMethod · 0.45
set_resultMethod · 0.45

Tested by

no test coverage detected