Browse Source

Adds a pool argument to celery.default_connection, which if set to False means that the pool won't be used to create a new connection

Ask Solem 12 years ago
parent
commit
70ccd41f95
1 changed files with 7 additions and 3 deletions
  1. 7 3
      celery/app/base.py

+ 7 - 3
celery/app/base.py

@@ -213,12 +213,16 @@ class Celery(object):
     broker_connection = connection
 
     @contextmanager
-    def default_connection(self, connection=None, *args, **kwargs):
+    def default_connection(self, connection=None, pool=True, *args, **kwargs):
         if connection:
             yield connection
         else:
-            with self.pool.acquire(block=True) as connection:
-                yield connection
+            if pool:
+                with self.pool.acquire(block=True) as connection:
+                    yield connection
+            else:
+                with self.connection() as connection:
+                    yield connection
 
     @contextmanager
     def default_producer(self, producer=None):