Outils pour utilisateurs

Outils du site


python:programmes:timeout

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

python:programmes:timeout [2013/06/04 20:33] – créée rootpython:programmes:timeout [2013/06/04 20:34] (Version actuelle) root
Ligne 27: Ligne 27:
  
     return decorator     return decorator
 +</code>
 +
 +<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 "Connection timed out"
 +@timeout(30, os.strerror(errno.ETIMEDOUT))
 +def long_running_function3()
 </code> </code>
python/programmes/timeout.1370378025.txt.gz · Dernière modification : 2013/06/04 20:33 de root