I want to write a function which will return after 5 seconds no matter what:
def myfunction():
while passed_time < 5_seconds:
do1()
do2()
do3()
.
.
return
I mean, this function run for 5 seconds only, after 5 seconds, it should end, and continue with other function:
myfunction()
otherfunction() ----> This should start 5 seconds after myfunction() is executed.
Best Regards
You can do:
Note that this will stop after at least 5 seconds – if
do1,do2, anddo3each take 3 seconds, then this function will take 9 seconds.If you want to cut off
myFunctionbetween these calls, you can do:This case would take 6s