Changeset - aa8680af29c2
[Not reviewed]
default
0 3 0
Mads Kiilerich (mads) - 5 years ago 2020-11-06 18:57:56
mads@kiilerich.com
Grafted from: 3c2910a2aead
celery: drop kallithea.CELERY_EAGER - it is more spot-on to look directly at task_always_eager

The global flag was set as a side effect in the make_app function. That's not
pretty.
3 files changed with 1 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/__init__.py
Show inline comments
 
@@ -38,13 +38,12 @@ VERSION = (0, 6, 99)
 
BACKENDS = {
 
    'hg': 'Mercurial repository',
 
    'git': 'Git repository',
 
}
 

	
 
CELERY_APP = None  # set to Celery app instance if using Celery
 
CELERY_EAGER = False
 

	
 
CONFIG = {}
 

	
 
# URL prefix for non repository related links - must start with `/`
 
ADMIN_PREFIX = '/_admin'
 
URL_SEP = '/'
kallithea/lib/celery_app.py
Show inline comments
 
@@ -16,14 +16,12 @@ mandatory settings.
 

	
 
import logging
 

	
 
import celery
 
import tg
 

	
 
import kallithea
 

	
 

	
 
class CeleryConfig(object):
 
    imports = ['kallithea.model.async_tasks']
 
    task_always_eager = False
 

	
 
list_config_names = {'imports', 'accept_content'}
 
@@ -76,9 +74,8 @@ def make_celery_config(config):
 

	
 

	
 
def make_app():
 
    """Create celery app from the TurboGears configuration file"""
 
    app = celery.Celery()
 
    celery_config = make_celery_config(tg.config)
 
    kallithea.CELERY_EAGER = celery_config.task_always_eager
 
    app.config_from_object(celery_config)
 
    return app
kallithea/lib/celerylib/__init__.py
Show inline comments
 
@@ -124,10 +124,10 @@ def get_session():
 
def dbsession(func):
 
    def __wrapper(func, *fargs, **fkwargs):
 
        try:
 
            ret = func(*fargs, **fkwargs)
 
            return ret
 
        finally:
 
            if kallithea.CELERY_APP and not kallithea.CELERY_EAGER:
 
            if kallithea.CELERY_APP and not kallithea.CELERY_APP.conf.task_always_eager:
 
                meta.Session.remove()
 

	
 
    return decorator(__wrapper, func)
0 comments (0 inline, 0 general)