From a69702cd83ad708fb834294d98217811faec8456 Mon Sep 17 00:00:00 2001 From: lukasheinrich Date: Wed, 8 Nov 2017 16:06:11 +0100 Subject: [PATCH] celery backend: add switch to tweak disable sync in result.get() this is necessary if you are running multiple independent celery instances (such as in yadage service cluster) --- packtivity/asyncbackends.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packtivity/asyncbackends.py b/packtivity/asyncbackends.py index caf8c6d..c0f4f35 100644 --- a/packtivity/asyncbackends.py +++ b/packtivity/asyncbackends.py @@ -4,6 +4,7 @@ import traceback import os import logging +import yaml from .syncbackends import run_packtivity from .syncbackends import prepublish @@ -196,13 +197,14 @@ class CeleryBackend(PythonCallableAsyncBackend): def __init__(self,app = None, packconfig_spec = None): super(CeleryBackend,self).__init__(packconfig_spec) self.app = app or default_celeryapp + self.disable_sync = yaml.load(os.environ.get('PACKTIVITY_CELERY_DISABLE_SYNC','true')) def submit_callable(self,callable): self.app.set_current() return CeleryProxy(run_nullary.apply_async(kwargs = {'nullary': callable})) def result(self,resultproxy): - return resultproxy.proxy.get() + return resultproxy.proxy.get(disable_sync_subtasks = self.disable_sync) def ready(self,resultproxy): return resultproxy.proxy.ready()