How to make a function retun after 5 second passes in python?

Posted by alwbtc on Stack Overflow See other posts from Stack Overflow or by alwbtc
Published on 2012-08-31T14:06:25Z Indexed on 2012/08/31 21:38 UTC
Read the original article Hit count: 177

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about python

Related posts about function