Skip to content
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

Add job.fail #1484

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add job.fail #1484

wants to merge 4 commits into from

Conversation

rpkak
Copy link
Contributor

@rpkak rpkak commented Jun 2, 2021

Added method job.fail to fail the job using a method.

job.fail takes some args to change the failture behavior. Not specifying anything affects the same as raising an exception, apart from printing the traceback which is disabled by default in job.fail.

For review: Please tell me if I should change exc_info to orig_exc_info in some places in

rq/rq/worker.py

Lines 1045 to 1051 in 2ee3416

exc_string = ''.join(traceback.format_exception(*exc_info))
self.handle_job_failure(job=job, exc_string=exc_string, queue=queue,
started_job_registry=started_job_registry, retry=job_failture.retry,
seconds_until_next_retry=job_failture.seconds_until_next_retry,
decrease_retries=job_failture.decrease_retries)
self.handle_exception(job, *exc_info, show_traceback=job_failture.show_traceback,
use_exc_handlers=job_failture.use_exc_handlers)

Closes #1313
View: #1313 (comment)

@codecov
Copy link

codecov bot commented Jun 2, 2021

Codecov Report

Merging #1484 (30fc219) into master (35604f9) will decrease coverage by 0.05%.
The diff coverage is 88.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1484      +/-   ##
==========================================
- Coverage   95.14%   95.09%   -0.06%     
==========================================
  Files          45       45              
  Lines        6246     6338      +92     
==========================================
+ Hits         5943     6027      +84     
- Misses        303      311       +8     
Impacted Files Coverage Δ
tests/fixtures.py 70.44% <28.57%> (-1.93%) ⬇️
rq/worker.py 89.40% <80.64%> (+0.14%) ⬆️
tests/test_job.py 99.57% <94.73%> (-0.43%) ⬇️
rq/exceptions.py 92.59% <100.00%> (+3.11%) ⬆️
rq/job.py 98.04% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 35604f9...30fc219. Read the comment docs.

@rpkak
Copy link
Contributor Author

rpkak commented Jun 6, 2021

I don't think I can add some more tests increase the coverage.

@selwin
Copy link
Collaborator

selwin commented Jun 12, 2021

@rpkak please see my comment here. Do you think this PR is still relevant?

@rpkak
Copy link
Contributor Author

rpkak commented Jun 12, 2021

@rpkak please see my comment here. Do you think this PR is still relevant?

Yes, I think in special cases of a job failture the customizability of the function will usefull.

Resolved merge conflicts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is it possible to fail a job other than by raising an exception?
2 participants