Created
October 8, 2021 22:29
-
-
Save subzero112233/37b840743001be09cfe7294e59809c74 to your computer and use it in GitHub Desktop.
Timeout a function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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