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

Method shutdown

Lib/concurrent/futures/thread.py:254–273  ·  view source on GitHub ↗
(self, wait=True, *, cancel_futures=False)

Source from the content-addressed store, hash-verified

252 work_item.future.set_exception(self.BROKEN(self._broken))
253
254 def shutdown(self, wait=True, *, cancel_futures=False):
255 with self._shutdown_lock:
256 self._shutdown = True
257 if cancel_futures:
258 # Drain all work items from the queue, and then cancel their
259 # associated futures.
260 while True:
261 try:
262 work_item = self._work_queue.get_nowait()
263 except queue.Empty:
264 break
265 if work_item is not None:
266 work_item.future.cancel()
267
268 # Send a wake-up to prevent threads calling
269 # _work_queue.get(block=True) from permanently blocking.
270 self._work_queue.put(None)
271 if wait:
272 for t in self._threads:
273 t.join()
274 shutdown.__doc__ = _base.Executor.shutdown.__doc__

Calls 4

get_nowaitMethod · 0.45
cancelMethod · 0.45
putMethod · 0.45
joinMethod · 0.45