Skip to content

Instantly share code, notes, and snippets.

@ddickstein
ddickstein / TryUntilTimeout.py
Last active December 19, 2015 16:48
Often it is useful to run some function that tries to do something, then run a check to see if it was done, and if not, try again and keep trying for some amount of time t. These functions can help.
import time
#
# Often it is useful to run some function that tries to do something,
# then run a check to see if it was done, and if not, try again and
# keep trying for some amount of time t. This function is designed
# to accomplish that.
#
def loop_func1_until_func2_or_timeout(func1,func2,args1=None,args2=None,
message=None,pause=10,timeout=120):