From f668d9d423e8082eda9fea65ee36f8f8a615c782 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Wed, 27 Apr 2016 14:58:42 +0200 Subject: [PATCH] [backend] Allow settings to be defined for worker subprocesses --- beat/web/backend/schedule.py | 7 +++++-- beat/web/scripts/worker.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/beat/web/backend/schedule.py b/beat/web/backend/schedule.py index 8234642d9..cea079a97 100644 --- a/beat/web/backend/schedule.py +++ b/beat/web/backend/schedule.py @@ -405,7 +405,7 @@ def worker_update(): @transaction.atomic -def work(environments, cpulimit, process): +def work(environments, cpulimit, process, settings): '''Launches user code on isolated processes This function is supposed to be called asynchronously, by a scheduling @@ -429,6 +429,9 @@ def work(environments, cpulimit, process): process (str): The path to the ``process.py`` program to use for running the user code on isolated processes. + settings (str): The name of the module containing the Django settings for + use with the process program + ''' # myself, raises if I cannot find me @@ -441,7 +444,7 @@ def work(environments, cpulimit, process): j.end(None, Job.CANCELLED) # cmdline base argument - cmdline = [process] + cmdline = [process, '--settings=%s' % settings] if cpulimit is not None: cmdline += ['--cpulimit=%s' % cpulimit] if settings.DEBUG: cmdline += ['-vv'] diff --git a/beat/web/scripts/worker.py b/beat/web/scripts/worker.py index 21f447298..d5c17b06e 100644 --- a/beat/web/scripts/worker.py +++ b/beat/web/scripts/worker.py @@ -124,7 +124,7 @@ def main(user_input=None): while not stop: start = time.time() - work(environments, cpulimit, process) + work(environments, cpulimit, process, arguments['--settings']) currtime = time.time() duration = currtime - start -- GitLab