Skip to content

Instantly share code, notes, and snippets.

@subzero112233
Created October 8, 2021 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subzero112233/37b840743001be09cfe7294e59809c74 to your computer and use it in GitHub Desktop.
Save subzero112233/37b840743001be09cfe7294e59809c74 to your computer and use it in GitHub Desktop.
Timeout a function
import time
import timeout_decorator
@timeout_decorator.timeout(5)
def mytest():
print("Start")
for i in range(1,10):
time.sleep(1)
print("{} seconds have passed".format(i))
if __name__ == '__main__':
mytest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment