(func, args, timeout)
| 32 | |
| 33 | |
| 34 | def function_with_timeout(func, args, timeout): |
| 35 | result_container = [] |
| 36 | |
| 37 | def wrapper(): |
| 38 | result_container.append(func(*args)) |
| 39 | |
| 40 | thread = PropagatingThread(target=wrapper) |
| 41 | thread.start() |
| 42 | thread.join(timeout) |
| 43 | |
| 44 | if thread.is_alive(): |
| 45 | raise TimeoutError() |
| 46 | else: |
| 47 | return result_container[0] |
| 48 | |
| 49 |
no test coverage detected