Now you can set CELERY_ALWAYS_EAGER environment variable so that you
authorChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 20 May 2011 23:49:04 +0000 (18:49 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 20 May 2011 23:49:04 +0000 (18:49 -0500)
don't have to run celeryd at the same time.

This should make Elrond happy ;)

mediagoblin/app.py
mediagoblin/celery_setup/__init__.py

index 640ffc45969d6bde4c0256c87db1f8436fda159d..714404deeef23d31b5fc6fdca3a41b2d29f7f6fc 100644 (file)
@@ -14,6 +14,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import os
 import urllib
 
 import routes
@@ -138,7 +139,12 @@ def paste_app_factory(global_config, **app_config):
         raise ImproperlyConfigured(
             "One of direct_remote_path or direct_remote_paths must be provided")
 
-    setup_celery_from_config(app_config, global_config)
+    if asbool(os.environ.get('CELERY_ALWAYS_EAGER')):
+        setup_celery_from_config(
+            app_config, global_config,
+            force_celery_always_eager=True)
+    else:
+        setup_celery_from_config(app_config, global_config)
 
     mgoblin_app = MediaGoblinApp(
         connection, db,
index 551b2741d510166f4bec3406efd8c1aec4263cfb..1a77cc6242ede3afe6cb97385467c55e62f83c34 100644 (file)
@@ -76,6 +76,7 @@ DEFAULT_SETTINGS_MODULE = 'mediagoblin.celery_setup.dummy_settings_module'
 
 def setup_celery_from_config(app_config, global_config,
                              settings_module=DEFAULT_SETTINGS_MODULE,
+                             force_celery_always_eager=False,
                              set_environ=True):
     """
     Take a mediagoblin app config and the global config from a paste
@@ -85,6 +86,7 @@ def setup_celery_from_config(app_config, global_config,
     - app_config: the application config section
     - global_config: the entire paste config, all sections
     - settings_module: the module to populate, as a string
+    - 
     - set_environ: if set, this will CELERY_CONFIG_MODULE to the
       settings_module
     """
@@ -136,6 +138,9 @@ def setup_celery_from_config(app_config, global_config,
     celery_imports = celery_settings.setdefault('CELERY_IMPORTS', [])
     celery_imports.extend(MANDATORY_CELERY_IMPORTS)
 
+    if force_celery_always_eager:
+        celery_settings['CELERY_ALWAYS_EAGER'] = True
+
     __import__(settings_module)
     this_module = sys.modules[settings_module]