Skip to content

Instantly share code, notes, and snippets.

@jriddy
Created December 11, 2015 22:51
Show Gist options
  • Save jriddy/ff8ef0ad0f6f58ea10b3 to your computer and use it in GitHub Desktop.
Save jriddy/ff8ef0ad0f6f58ea10b3 to your computer and use it in GitHub Desktop.
@defer.inlineCallbacks
def retry(self, method, *args, **kwds):
for i in xrange(self.tries):
try:
result = yield method(*args, **kwds)
except:
if i == self.tries - 1:
raise
else:
defer.returnValue(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment