Last active
December 28, 2015 20:49
-
-
Save netmarkjp/7559988 to your computer and use it in GitHub Desktop.
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 | |
def check_hoge(**args): | |
print "args:", | |
print args | |
return False | |
def wait(function_name, retry=5, interval=1, **args): | |
try_count = 1 | |
while not globals()[function_name](**args): | |
time.sleep(interval) | |
if try_count > retry: | |
raise Exception("retry over tried %d times" % try_count) | |
try_count = try_count + 1 | |
try: | |
print "retry 2" | |
wait("check_hoge", 2, 1, myarg1=10, myarg2=20) | |
except Exception as e: | |
print e | |
try: | |
print "retry 1" | |
wait("check_hoge", 1, 1, myarg1=10, myarg2=20) | |
except Exception as e: | |
print e | |
try: | |
print "retry 0" | |
wait("check_hoge", 0, 1, myarg1=10, myarg2=20) | |
except Exception as e: | |
print e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use
globals()[function_name]
orgetattr(self,function_name)