horse should always call os._exit(0)

This commit is contained in:
Selwin Ong 2018-09-23 20:40:09 +07:00
parent cc19d1a89e
commit 4759c43067
2 changed files with 11 additions and 11 deletions

2
.gitignore vendored
View File

@ -15,3 +15,5 @@ Vagrantfile
.idea/ .idea/
.coverage* .coverage*
/.cache /.cache
.pytest_cache/

View File

@ -463,7 +463,6 @@ class Worker(object):
""" """
setup_loghandlers(logging_level, date_format, log_format) setup_loghandlers(logging_level, date_format, log_format)
self._install_signal_handlers() self._install_signal_handlers()
did_perform_work = False did_perform_work = False
self.register_birth() self.register_birth()
self.log.info("RQ worker {0!r} started, version {1}".format(self.key, VERSION)) self.log.info("RQ worker {0!r} started, version {1}".format(self.key, VERSION))
@ -671,16 +670,15 @@ class Worker(object):
# that are different from the worker. # that are different from the worker.
random.seed() random.seed()
self.setup_work_horse_signals() try:
self.setup_work_horse_signals()
self._is_horse = True self._is_horse = True
self.log = logger self.log = logger
self.perform_job(job, queue)
success = self.perform_job(job, queue) finally:
# 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(0)
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."""