(func, args, timeout)
| 20 | |
| 21 | |
| 22 | def function_with_timeout(func, args, timeout): |
| 23 | r = [] |
| 24 | def w(): |
| 25 | r.append(func(*args)) |
| 26 | t = _PropagatingThread(target=w) |
| 27 | t.start() |
| 28 | t.join(timeout) |
| 29 | if t.is_alive(): |
| 30 | raise TimeoutError() |
| 31 | return r[0] |
no test coverage detected