I have a website running on Heroku in Python, and I have a worker as a background process for handling tasks that I don’t want to block the delivery of the web page, and therefore are not suitable for web speakers. To do this, I configured the queue using rq and redid it.
In my process, sometimes user exceptions may occur. For a specific subset of them, instead of letting the job go directly to the crash queue, I want to request it several times. I looked at the exception handlers page on the rq homepage and I don't quite understand some things. In particular, it describes the following method of writing an exception handler:
def my_handler(job, exc_type, exc_value, traceback):
Now I plan to do something like:
from rq import requeue_job def my_handler(job, exc_type, exc_value, traceback): if exec_type == "MyCustomError": job.meta['MyErrorCount'] += 1 job.save() if job.meta['MyErrorCount'] >= 10: return True else: requeue_job(job.id) return False
Questions:
- What are the objects
exc_type , exc_value and traceback ? (for example, is the if exec_type == "MyCustomError" correct?) - Will my error handler effectively detect if this is a specific error, request these jobs until it works 10 times, and then let it fall to
failed ? Will it also allow all other errors to fall to failed ?
source share