| Conditions | 4 |
| Total Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | from functools import wraps |
||
| 8 | def timeout(seconds=5): |
||
| 9 | def decorator(func): |
||
| 10 | def wrapper(*args, **kwargs): |
||
| 11 | process = Process(None, func, None, args, kwargs) |
||
| 12 | process.start() |
||
| 13 | process.join(seconds) |
||
| 14 | if process.is_alive(): |
||
| 15 | process.terminate() |
||
| 16 | return wraps(func)(wrapper) |
||
| 17 | return decorator |
||
| 18 |