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

Class _PoolCache

Lib/multiprocessing/pool.py:150–171  ·  view source on GitHub ↗

Class that implements a cache for the Pool class that will notify the pool management threads every time the cache is emptied. The notification is done by the use of a queue that is provided when instantiating the cache.

Source from the content-addressed store, hash-verified

148#
149
150class _PoolCache(dict):
151 """
152 Class that implements a cache for the Pool class that will notify
153 the pool management threads every time the cache is emptied. The
154 notification is done by the use of a queue that is provided when
155 instantiating the cache.
156 """
157 def __init__(self, /, *args, notifier=None, **kwds):
158 self.notifier = notifier
159 super().__init__(*args, **kwds)
160
161 def __delitem__(self, item):
162 super().__delitem__(item)
163
164 # Notify that the cache is empty. This is important because the
165 # pool keeps maintaining workers until the cache gets drained. This
166 # eliminates a race condition in which a task is finished after the
167 # the pool's _handle_workers method has enter another iteration of the
168 # loop. In this situation, the only event that can wake up the pool
169 # is the cache to be emptied (no more tasks available).
170 if not self:
171 self.notifier.put(None)
172
173class Pool(object):
174 '''

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…