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

Function call_within

tests/process_helpers.py:55–67  ·  view source on GitHub ↗
(call: Callable[[], object], seconds: float)

Source from the content-addressed store, hash-verified

53
54
55def call_within(call: Callable[[], object], seconds: float) -> tuple[bool, BaseException | None]: # pragma: win32 cover
56 raised: list[BaseException] = []
57
58 def run() -> None:
59 try:
60 call()
61 except Exception as error: # handed to the caller, which asserts on it
62 raised.append(error)
63
64 thread = threading.Thread(target=run, daemon=True)
65 thread.start()
66 thread.join(seconds)
67 return not thread.is_alive(), next(iter(raised), None)
68
69
70__all__ = [

Calls 1

joinMethod · 0.80