Browse Source

Must now pass app to Backend()

Ask Solem 11 years ago
parent
commit
28e0d393d9
3 changed files with 8 additions and 8 deletions
  1. 2 2
      celery/backends/amqp.py
  2. 4 4
      celery/backends/base.py
  3. 2 2
      celery/backends/cache.py

+ 2 - 2
celery/backends/amqp.py

@@ -59,10 +59,10 @@ class AMQPBackend(BaseBackend):
         'interval_max': 1,
     }
 
-    def __init__(self, connection=None, exchange=None, exchange_type=None,
+    def __init__(self, app, connection=None, exchange=None, exchange_type=None,
                  persistent=None, serializer=None, auto_delete=True,
                  **kwargs):
-        super(AMQPBackend, self).__init__(**kwargs)
+        super(AMQPBackend, self).__init__(app, **kwargs)
         conf = self.app.conf
         self._connection = connection
         self.queue_arguments = {}

+ 4 - 4
celery/backends/base.py

@@ -41,7 +41,8 @@ PY3 = sys.version_info >= (3, 0)
 
 def unpickle_backend(cls, args, kwargs):
     """Returns an unpickled backend."""
-    return cls(*args, **kwargs)
+    from celery import current_app
+    return cls(*args, app=current_app._get_current_object(), **kwargs)
 
 
 class BaseBackend(object):
@@ -64,10 +65,9 @@ class BaseBackend(object):
     #: in this case.
     supports_autoexpire = False
 
-    def __init__(self, app=None, serializer=None,
+    def __init__(self, app, serializer=None,
                  max_cached_results=None, **kwargs):
-        from celery.app import app_or_default
-        self.app = app_or_default(app)
+        self.app = app
         conf = self.app.conf
         self.serializer = serializer or conf.CELERY_RESULT_SERIALIZER
         (self.content_type,

+ 2 - 2
celery/backends/cache.py

@@ -85,8 +85,8 @@ class CacheBackend(KeyValueStoreBackend):
     supports_native_join = True
     implements_incr = True
 
-    def __init__(self, expires=None, backend=None, options={}, **kwargs):
-        super(CacheBackend, self).__init__(**kwargs)
+    def __init__(self, app, expires=None, backend=None, options={}, **kwargs):
+        super(CacheBackend, self).__init__(app, **kwargs)
 
         self.options = dict(self.app.conf.CELERY_CACHE_BACKEND_OPTIONS,
                             **options)