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

Class MultiprocessIterator

Lib/test/libregrtest/run_workers.py:52–71  ·  view source on GitHub ↗

A thread-safe iterator over tests for multiprocess mode.

Source from the content-addressed store, hash-verified

50
51# We do not use a generator so multiple threads can call next().
52class MultiprocessIterator:
53
54 """A thread-safe iterator over tests for multiprocess mode."""
55
56 def __init__(self, tests_iter):
57 self.lock = threading.Lock()
58 self.tests_iter = tests_iter
59
60 def __iter__(self):
61 return self
62
63 def __next__(self):
64 with self.lock:
65 if self.tests_iter is None:
66 raise StopIteration
67 return next(self.tests_iter)
68
69 def stop(self):
70 with self.lock:
71 self.tests_iter = None
72
73
74@dataclasses.dataclass(slots=True, frozen=True)

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…