Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
horse should always call os._exit(0)
  • Loading branch information
selwin committed Sep 23, 2018
1 parent cc19d1a commit 4759c43
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -15,3 +15,5 @@ Vagrantfile
.idea/
.coverage*
/.cache

.pytest_cache/
20 changes: 9 additions & 11 deletions rq/worker.py
Expand Up @@ -463,7 +463,6 @@ def work(self, burst=False, logging_level="INFO", date_format=DEFAULT_LOGGING_DA
"""
setup_loghandlers(logging_level, date_format, log_format)
self._install_signal_handlers()

did_perform_work = False
self.register_birth()
self.log.info("RQ worker {0!r} started, version {1}".format(self.key, VERSION))
Expand Down Expand Up @@ -671,16 +670,15 @@ def main_work_horse(self, job, queue):
# that are different from the worker.
random.seed()

self.setup_work_horse_signals()

self._is_horse = True
self.log = logger

success = self.perform_job(job, queue)

# os._exit() is the way to exit from childs after a fork(), in
# constrast to the regular sys.exit()
os._exit(0)
try:
self.setup_work_horse_signals()
self._is_horse = True
self.log = logger
self.perform_job(job, queue)
finally:
# os._exit() is the way to exit from childs after a fork(), in
# constrast to the regular sys.exit()
os._exit(0)

def setup_work_horse_signals(self):
"""Setup signal handing for the newly spawned work horse."""
Expand Down

0 comments on commit 4759c43

Please sign in to comment.