Browse Source

Chords now work again for 2.6

Ask Solem 13 years ago
parent
commit
c5c393107a
2 changed files with 11 additions and 2 deletions
  1. 1 1
      celery/app/builtins.py
  2. 10 1
      celery/worker/__init__.py

+ 1 - 1
celery/app/builtins.py

@@ -89,6 +89,6 @@ def add_chord_task(app):
                                    max_retries=max_retries,
                                    propagate=propagate,
                                    result=r)
-        return set.apply_async(taskset_id=setid)
+        set.apply_async(taskset_id=setid)
 
     return chord

+ 10 - 1
celery/worker/__init__.py

@@ -24,7 +24,7 @@ import traceback
 from kombu.utils.finalize import Finalize
 
 from celery import concurrency as _concurrency
-from celery.app import app_or_default
+from celery.app import app_or_default, set_default_app
 from celery.app.abstract import configurated, from_config
 from celery.exceptions import SystemTerminate
 from celery.utils.functional import noop
@@ -199,6 +199,15 @@ class WorkController(configurated):
             ready_callback=noop,
             queues=None, app=None, **kwargs):
         self.app = app_or_default(app or self.app)
+
+        # all new threads start without a current app, so if an app is not
+        # passed on to the thread it will fall back to the "default app",
+        # which then could be the wrong app.  So for the worker
+        # we set this to always return our app.  This is a hack,
+        # and means that only a single app can be used for workers
+        # running in the same process.
+        set_default_app(self.app)
+
         self._shutdown_complete = threading.Event()
         self.setup_defaults(kwargs, namespace="celeryd")
         self.app.select_queues(queues)  # select queues subset.