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_worker_ttl=worker_ttl,
default_result_ttl=results_ttl, default_result_ttl=results_ttl,
job_class=job_class, job_class=job_class,
exception_handlers=exception_handlers) exception_handlers=exception_handlers or None)
# Should we configure Sentry? # Should we configure Sentry?
if sentry_dsn: if sentry_dsn:

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

Loading…
Cancel
Save