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

Method shutdown

Lib/queue.py:233–256  ·  view source on GitHub ↗

Shut-down the queue, making queue gets and puts raise ShutDown. 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', the q

(self, immediate=False)

Source from the content-addressed store, hash-verified

231 return self.get(block=False)
232
233 def shutdown(self, immediate=False):
234 '''Shut-down the queue, making queue gets and puts raise ShutDown.
235
236 By default, gets will only raise once the queue is empty. Set
237 'immediate' to True to make gets raise immediately instead.
238
239 All blocked callers of put() and get() will be unblocked.
240
241 If 'immediate', the queue is drained and unfinished tasks
242 is reduced by the number of drained tasks. If unfinished tasks
243 is reduced to zero, callers of Queue.join are unblocked.
244 '''
245 with self.mutex:
246 self.is_shutdown = True
247 if immediate:
248 while self._qsize():
249 self._get()
250 if self.unfinished_tasks > 0:
251 self.unfinished_tasks -= 1
252 # release all blocked threads in `join()`
253 self.all_tasks_done.notify_all()
254 # All getters need to re-check queue-empty to raise ShutDown
255 self.not_empty.notify_all()
256 self.not_full.notify_all()
257
258 # Override these methods to implement other queue organizations
259 # (e.g. stack or priority queue).

Callers 2

closeMethod · 0.45
listenerMethod · 0.45

Calls 3

_qsizeMethod · 0.95
_getMethod · 0.95
notify_allMethod · 0.45

Tested by

no test coverage detected