(*args, **kwargs)
| 302 | def decorator(func): |
| 303 | @wraps(func) |
| 304 | def wrapper(*args, **kwargs): |
| 305 | result = None |
| 306 | exception = None |
| 307 | |
| 308 | def target() -> None: |
| 309 | nonlocal result, exception |
| 310 | try: |
| 311 | result = func(*args, **kwargs) |
| 312 | except Exception as e: |
| 313 | exception = e |
| 314 | |
| 315 | thread = threading.Thread(target=target) |
| 316 | thread.daemon = True |
| 317 | thread.start() |
| 318 | thread.join(timeout=timeout_seconds) |
| 319 | |
| 320 | if thread.is_alive(): |
| 321 | raise TimeoutError(f'Function timed out after {timeout_seconds} seconds') |
| 322 | if exception is not None: |
| 323 | raise exception |
| 324 | return result |
| 325 | |
| 326 | return wrapper |
| 327 |
nothing calls this directly
no test coverage detected
searching dependent graphs…