worker.main_work_horse should always return 0

main
Selwin Ong 7 years ago
parent 0a47717fd2
commit 531fde8e3c

@ -678,7 +678,7 @@ class Worker(object):
# os._exit() is the way to exit from childs after a fork(), in # os._exit() is the way to exit from childs after a fork(), in
# constrast to the regular sys.exit() # constrast to the regular sys.exit()
os._exit(int(not success)) os._exit(0)
def setup_work_horse_signals(self): def setup_work_horse_signals(self):
"""Setup signal handing for the newly spawned work horse.""" """Setup signal handing for the newly spawned work horse."""
@ -801,8 +801,7 @@ class Worker(object):
self.handle_job_success(job=job, self.handle_job_success(job=job,
queue=queue, queue=queue,
started_job_registry=started_job_registry) started_job_registry=started_job_registry)
except Exception: except:
job.ended_at = utcnow() job.ended_at = utcnow()
self.handle_job_failure(job=job, self.handle_job_failure(job=job,
started_job_registry=started_job_registry) started_job_registry=started_job_registry)

@ -871,7 +871,7 @@ class WorkerShutdownTestCase(TimeoutTestCase, RQTestCase):
@slow @slow
def test_working_worker_cold_shutdown(self): def test_working_worker_cold_shutdown(self):
"""worker with an ongoing job receiving double SIGTERM signal and shutting down immediately""" """Busy worker shuts down immediately on double SIGTERM signal"""
fooq = Queue('foo') fooq = Queue('foo')
w = Worker(fooq) w = Worker(fooq)
sentinel_file = '/tmp/.rq_sentinel_cold' sentinel_file = '/tmp/.rq_sentinel_cold'
@ -1045,13 +1045,6 @@ class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase):
class TestExceptionHandlerMessageEncoding(RQTestCase): class TestExceptionHandlerMessageEncoding(RQTestCase):
def test_handle_exception_handles_non_ascii_in_exception_message(self):
"""Test that handle_exception doesn't crash on non-ascii in exception message."""
self.worker.handle_exception(Mock(), *self.exc_info)
def test_move_to_failed_queue_handles_non_ascii_in_exception_message(self):
"""Test that move_to_failed_queue doesn't crash on non-ascii in exception message."""
self.worker.move_to_failed_queue(Mock(), *self.exc_info)
def setUp(self): def setUp(self):
super(TestExceptionHandlerMessageEncoding, self).setUp() super(TestExceptionHandlerMessageEncoding, self).setUp()
@ -1063,3 +1056,11 @@ class TestExceptionHandlerMessageEncoding(RQTestCase):
raise Exception(u"💪") raise Exception(u"💪")
except: except:
self.exc_info = sys.exc_info() self.exc_info = sys.exc_info()
def test_handle_exception_handles_non_ascii_in_exception_message(self):
"""worker.handle_exception doesn't crash on non-ascii in exception message."""
self.worker.handle_exception(Mock(), *self.exc_info)
def test_move_to_failed_queue_handles_non_ascii_in_exception_message(self):
"""Test that move_to_failed_queue doesn't crash on non-ascii in exception message."""
self.worker.move_to_failed_queue(Mock(), *self.exc_info)

Loading…
Cancel
Save