python:programmes:timeout
Différences
Ci-dessous, les différences entre deux révisions de la page.
python:programmes:timeout [2013/06/04 20:33] – créée root | python:programmes:timeout [2013/06/04 20:34] (Version actuelle) – root | ||
---|---|---|---|
Ligne 27: | Ligne 27: | ||
return decorator | return decorator | ||
+ | </ | ||
+ | |||
+ | <code python exemple1.py> | ||
+ | from timeout import timeout | ||
+ | |||
+ | # Timeout a long running function with the default expiry of 10 seconds. | ||
+ | @timeout | ||
+ | def long_running_function1(): | ||
+ | ... | ||
+ | |||
+ | # Timeout after 5 seconds | ||
+ | @timeout(5) | ||
+ | def long_running_function2(): | ||
+ | ... | ||
+ | |||
+ | # Timeout after 30 seconds, with the error " | ||
+ | @timeout(30, | ||
+ | def long_running_function3() | ||
</ | </ |
python/programmes/timeout.1370378025.txt.gz · Dernière modification : 2013/06/04 20:33 de root