Document retry function

This commit is contained in:
Brandon Heller
2009-12-19 19:21:18 -08:00
parent 2e52801de5
commit fabbac885f
+7 -1
View File
@@ -399,7 +399,13 @@ def moveIntf( intf, node, print_error = False ):
return True
def retry( n, retry_delay, fn, *args):
"Try something N times before giving up."
'''Try something N times before giving up.
@param n number of times to retry
@param retry_delay seconds wait this long between tries
@param fn function to call
@param args args to apply to function call
'''
tries = 0
while not apply( fn, args ) and tries < n:
sleep( retry_delay )