Running rqworker without specifiying --exception-handler shouldn't override default behavior.

main
Selwin Ong 10 years ago
parent 04e403e1a3
commit 8bfbeac67d

@ -184,7 +184,7 @@ def worker(url, config, burst, name, worker_class, job_class, queue_class, path,
default_worker_ttl=worker_ttl,
default_result_ttl=results_ttl,
job_class=job_class,
exception_handlers=exception_handlers)
exception_handlers=exception_handlers or None)
# Should we configure Sentry?
if sentry_dsn:

@ -80,24 +80,19 @@ class TestRQCli(RQTestCase):
q = Queue()
failed_q = get_failed_queue()
failed_q.empty()
# Preconditions
self.assertEquals(failed_q.count, 0)
self.assertEquals(q.count, 0)
# Action
job = q.enqueue(div_by_zero)
self.assertEquals(q.count, 1)
runner = CliRunner()
result = runner.invoke(main, ['worker', '-u', self.redis_url, '-b', '--exception-handler', 'tests.fixtures.black_hole'])
self.assertEqual(result.exit_code, 0)
# Postconditions
self.assertEquals(q.count, 0)
self.assertEquals(failed_q.count, 0)
# Check the job
job = Job.fetch(job.id)
self.assertEquals(job.is_failed, True)
# If exception handler is not given, failed job goes to FailedQueue
q.enqueue(div_by_zero)
runner.invoke(main, ['worker', '-u', self.redis_url, '-b'])
self.assertEquals(failed_q.count, 1)
# Black hole exception handler doesn't add failed jobs to FailedQueue
q.enqueue(div_by_zero)
runner.invoke(main, ['worker', '-u', self.redis_url, '-b',
'--exception-handler', 'tests.fixtures.black_hole'])
self.assertEquals(failed_q.count, 1)
def test_suspend_and_resume(self):
"""rq suspend -u <url>

Loading…
Cancel
Save