MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _worker

Function _worker

tools/python-3.11.9-amd64/Lib/concurrent/futures/thread.py:69–109  ·  view source on GitHub ↗
(executor_reference, work_queue, initializer, initargs)

Source from the content-addressed store, hash-verified

67
68
69def _worker(executor_reference, work_queue, initializer, initargs):
70 if initializer is not None:
71 try:
72 initializer(*initargs)
73 except BaseException:
74 _base.LOGGER.critical('Exception in initializer:', exc_info=True)
75 executor = executor_reference()
76 if executor is not None:
77 executor._initializer_failed()
78 return
79 try:
80 while True:
81 work_item = work_queue.get(block=True)
82 if work_item is not None:
83 work_item.run()
84 # Delete references to object. See issue16284
85 del work_item
86
87 # attempt to increment idle count
88 executor = executor_reference()
89 if executor is not None:
90 executor._idle_semaphore.release()
91 del executor
92 continue
93
94 executor = executor_reference()
95 # Exit if:
96 # - The interpreter is shutting down OR
97 # - The executor that owns the worker has been collected OR
98 # - The executor that owns the worker has been shutdown.
99 if _shutdown or executor is None or executor._shutdown:
100 # Flag the executor as shutting down as early as possible if it
101 # is not gc-ed yet.
102 if executor is not None:
103 executor._shutdown = True
104 # Notice other workers
105 work_queue.put(None)
106 return
107 del executor
108 except BaseException:
109 _base.LOGGER.critical('Exception in worker', exc_info=True)
110
111
112class BrokenThreadPool(_base.BrokenExecutor):

Callers

nothing calls this directly

Calls 6

_initializer_failedMethod · 0.80
criticalMethod · 0.45
getMethod · 0.45
runMethod · 0.45
releaseMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected