-
Notifications
You must be signed in to change notification settings - Fork 956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pass the exception to failure hook #721
pass the exception to failure hook #721
Conversation
@@ -211,7 +211,7 @@ def run(job) | |||
|
|||
# Reschedule the job in the future (when a job fails). | |||
# Uses an exponential scale depending on the number of failed attempts. | |||
def reschedule(job, time = nil) | |||
def reschedule(job, time = nil, error = nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time
param is never used across the code. All tests still pass when removed. Can we get rid of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically part of the public API. Leave it.
00c7e65
to
27ce6b0
Compare
This needs to work with old failure callbacks that only accept 1 argument. This PR would break everyone's current code. |
@albus522 There haven't been any specs for error hooks, right? Will write and make sure all works OK. Please also answer my question in the code. |
Will submit a new PR when done. |
I use delayed_job to run background tasks in VirtKick, example tasks are creating a new machine, creating a new disk, mounting an ISO, etc. Some I/O related tasks can't be performed when load is high, libvirt is just rejecting the call. Therefore, I set some big
max_attempts
andreschedule_at
in 2 seconds. That's fine.I catch every unhandled exception with Bugsnag so as to know of every exception. The problem is this reports too much. If the job fails for the first time and succeeds for the second, one exception will be reported anyway. One way would be to check if
attempt == max_attempts
before reporting to Bugsnag, but I believe the best way is to introducedef failure(job, exception)
.I didn't write any specs at this point - tell me if you're OK with
def failure job, exception
first. :) Please also see my questions directly in the code.