Changeset - 7a73baa4c66c
[Not reviewed]
default
0 3 0
Mads Kiilerich (mads) - 5 years ago 2021-01-01 20:38:33
mads@kiilerich.com
Grafted from: 4299b38fdf59
celery: don't rely on CELERY_APP only being set (from app_cfg) when use_celery

We would rather always have CELERY_APP set.

Kind of backing out 894a662b12b3.
3 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_cli_celery.py
Show inline comments
 
@@ -17,6 +17,7 @@ import click
 

	
 
import kallithea
 
import kallithea.bin.kallithea_cli_base as cli_base
 
from kallithea.lib.utils2 import asbool
 

	
 

	
 
@cli_base.register_command(config_file_initialize_app=True)
 
@@ -32,7 +33,7 @@ def celery_run(celery_args):
 
    by this CLI command.
 
    """
 

	
 
    if not kallithea.CELERY_APP:
 
    if not asbool(kallithea.CONFIG.get('use_celery')):
 
        raise Exception('Please set use_celery = true in .ini config '
 
                        'file before running this command')
 

	
kallithea/lib/celerylib/__init__.py
Show inline comments
 
@@ -35,7 +35,7 @@ from tg import config
 

	
 
import kallithea
 
from kallithea.lib.pidlock import DaemonLock, LockHeld
 
from kallithea.lib.utils2 import safe_bytes
 
from kallithea.lib.utils2 import asbool, safe_bytes
 
from kallithea.model import meta
 

	
 

	
 
@@ -46,7 +46,7 @@ def task(f_org):
 
    """Wrapper of celery.task.task, running async if CELERY_APP
 
    """
 

	
 
    if kallithea.CELERY_APP:
 
    if asbool(kallithea.CONFIG.get('use_celery')):
 
        def f_async(*args, **kwargs):
 
            log.info('executing %s task', f_org.__name__)
 
            try:
kallithea/model/async_tasks.py
Show inline comments
 
@@ -219,7 +219,7 @@ def get_commits_stats(repo_name, ts_min_
 
        lock.release()
 

	
 
        # execute another task if celery is enabled
 
        if len(scm_repo.revisions) > 1 and kallithea.CELERY_APP and recurse_limit > 0:
 
        if len(scm_repo.revisions) > 1 and asbool(kallithea.CONFIG.get('use_celery')) and recurse_limit > 0:
 
            get_commits_stats(repo_name, ts_min_y, ts_max_y, recurse_limit - 1)
 
        elif recurse_limit <= 0:
 
            log.debug('Not recursing - limit has been reached')
0 comments (0 inline, 0 general)