MCPcopy Create free account
hub / github.com/tox-dev/filelock / WorkerThread

Class WorkerThread

tests/core/thread_helpers.py:17–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17class WorkerThread(threading.Thread):
18 def __init__(self, target: Callable[[], None], name: str) -> None:
19 super().__init__(target=target, name=name, daemon=True)
20 self.ex: _ExcInfoType | None = None
21
22 @override
23 def run(self) -> None:
24 try:
25 super().run()
26 except Exception: # pragma: no cover # a worker that raises fails the test; a healthy run never lands here
27 self.ex = sys.exc_info()
28
29 @override
30 def join(self, timeout: float | None = None) -> None:
31 super().join(timeout=timeout)
32 if self.ex is not None:
33 raise RuntimeError from self.ex[1] # pragma: no cover # only a worker that raised gets re-raised here
34
35
36# A hung worker would otherwise trigger pytest-timeout and kill the entire Windows session.

Calls

no outgoing calls