Browse Source

Removes deprecated Celery.with_default_connection (use with app.connection_or_acquire(connection=)

Ask Solem 11 years ago
parent
commit
437d0fdd77
3 changed files with 1 additions and 34 deletions
  1. 1 23
      celery/app/base.py
  2. 0 1
      celery/five.py
  3. 0 10
      celery/tests/app/test_app.py

+ 1 - 23
celery/app/base.py

@@ -15,7 +15,6 @@ import warnings
 from collections import Callable, defaultdict, deque
 from contextlib import contextmanager
 from copy import deepcopy
-from functools import wraps
 from operator import attrgetter
 
 from billiard.util import register_after_fork
@@ -179,8 +178,7 @@ class Celery(object):
             # the task instance from the current app.
             # Really need a better solution for this :(
             from . import shared_task as proxies_to_curapp
-            opts['_force_evaluate'] = True  # XXX Py2.5
-            return proxies_to_curapp(*args, **opts)
+            return proxies_to_curapp(*args, _force_evaluate=True, **opts)
 
         def inner_create_task_cls(shared=True, filter=None, **opts):
             _filt = filter  # stupid 2to3
@@ -336,26 +334,6 @@ class Celery(object):
                 yield producer
     default_producer = producer_or_acquire  # XXX compat
 
-    def with_default_connection(self, fun):
-        """With any function accepting a `connection`
-        keyword argument, establishes a default connection if one is
-        not already passed to it.
-
-        Any automatically established connection will be closed after
-        the function returns.
-
-        **Deprecated**
-
-        Use ``with app.connection_or_acquire(connection)`` instead.
-
-        """
-        @wraps(fun)
-        def _inner(*args, **kwargs):
-            connection = kwargs.pop('connection', None)
-            with self.connection_or_acquire(connection) as c:
-                return fun(*args, connection=c, **kwargs)
-        return _inner
-
     def prepare_config(self, c):
         """Prepare configuration before it is merged with the defaults."""
         return find_deprecated_settings(c)

+ 0 - 1
celery/five.py

@@ -238,7 +238,6 @@ COMPAT_MODULES = {
             'TaskPublisher': 'amqp.TaskPublisher',
             'TaskConsumer': 'amqp.TaskConsumer',
             'establish_connection': 'connection',
-            'with_connection': 'with_default_connection',
             'get_consumer_set': 'amqp.TaskConsumer',
         },
         'registry': {

+ 0 - 10
celery/tests/app/test_app.py

@@ -541,16 +541,6 @@ class test_App(Case):
         self.assertEqual(self.app.conf.BROKER_BACKEND,
                          self.app.conf.BROKER_TRANSPORT)
 
-    def test_with_default_connection(self):
-
-        @self.app.with_default_connection
-        def handler(connection=None, foo=None):
-            return connection, foo
-
-        connection, foo = handler(foo=42)
-        self.assertEqual(foo, 42)
-        self.assertTrue(connection)
-
     def test_after_fork(self):
         p = self.app._pool = Mock()
         self.app._after_fork(self.app)