You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Logging at WARN level isn't ideal, even if you can supply your own logger you still can't (easily) change the log level that messages go to.
A more generic way to implement this would be to pass in not a logger, but a log function that gets called with information about the failure, this gives you more flexibility in how you format your log message, what level you log it at, in fact, it also gives you the flexibility to do anything else following a failure. (e.g. re-establish a connection before the next retry attempt)
Add a handle_failure argument which takes an optional function that gets called following a failure.
Open question as to whether it should be called before the sleep (better suited to logging) or after the sleep (better suited to recycling resources closer to when they will be used e.g. re-opening an FTP connection before a long sleep only to have it timeout from inactivity during the sleep won't work well.)
Maybe need both after_failure and before_retry to cover all the bases?
after_failure could potentially return a value indicating whether to retry or not, or perhaps even a value that indicates how long to wait before the retry.
Thoughts?
The text was updated successfully, but these errors were encountered:
I'd very much like to see this feature implemented, and I'd like to share some inspiration.
In jaraco.functools, I implement retry_call without implicit sleep or logging behavior, but instead using a generic cleanup parameter, which can be set to sleep (functools.partial(time.sleep, 1)) or log or both or something else.
Logging at WARN level isn't ideal, even if you can supply your own logger you still can't (easily) change the log level that messages go to.
A more generic way to implement this would be to pass in not a logger, but a log function that gets called with information about the failure, this gives you more flexibility in how you format your log message, what level you log it at, in fact, it also gives you the flexibility to do anything else following a failure. (e.g. re-establish a connection before the next retry attempt)
Add a
handle_failure
argument which takes an optional function that gets called following a failure.Open question as to whether it should be called before the sleep (better suited to logging) or after the sleep (better suited to recycling resources closer to when they will be used e.g. re-opening an FTP connection before a long sleep only to have it timeout from inactivity during the sleep won't work well.)
Maybe need both
after_failure
andbefore_retry
to cover all the bases?after_failure
could potentially return a value indicating whether to retry or not, or perhaps even a value that indicates how long to wait before the retry.Thoughts?
The text was updated successfully, but these errors were encountered: