MCPcopy Index your code
hub / github.com/RustPython/RustPython / shutdown

Method shutdown

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

Source from the content-addressed store, hash-verified

218 work_item.future.set_exception(BrokenThreadPool(self._broken))
219
220 def shutdown(self, wait=True, *, cancel_futures=False):
221 with self._shutdown_lock:
222 self._shutdown = True
223 if cancel_futures:
224 # Drain all work items from the queue, and then cancel their
225 # associated futures.
226 while True:
227 try:
228 work_item = self._work_queue.get_nowait()
229 except queue.Empty:
230 break
231 if work_item is not None:
232 work_item.future.cancel()
233
234 # Send a wake-up to prevent threads calling
235 # _work_queue.get(block=True) from permanently blocking.
236 self._work_queue.put(None)
237 if wait:
238 for t in self._threads:
239 t.join()
240 shutdown.__doc__ = _base.Executor.shutdown.__doc__

Calls 4

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