Djangae contains a small collection of utility functions which are useful on App Engine.
This is a helper for calling functions which may intermittently throw errors. It is useful for things such as performing Datastore transactions which may collide, or calling other APIs which may occasionally fail but that should succeed on a subsequent attempt.
retry(function, _catch=None, _attempts=3, _initial_wait=375, _max_wait=30000)
Calls the given function, catching the given exception(s), and (re)trying up to a maximum of
If the intial call fails, it will wait
_initial_wait milliseconds before making the second attempt.
The wait will double on each subsequent retry, up to a maximum of
_catch defaults to:
( djangae.db.transaction.TransactionFailedError, google.appengine.api.datastore_errors.Error, google.appengine.runtime.apiproxy_errors.Error )
A function decorator which routes the function through
@retry_on_error(_catch=None, _attempts=3, _initial_wait=375, _max_wait=30000) def my_function(): ...
retry(function, _catch=None, _attempts=∞, _initial_wait=375, _max_wait=30000)
The same as
_attempts is unlimited, so it will keep on retrying until either it succeeds or you hit an uncaught exception, such as the App Engine