changeset 8826:7a73baa4c66c

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.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 01 Jan 2021 20:38:33 +0100
parents e9521559d013
children aa5cd5e44621
files kallithea/bin/kallithea_cli_celery.py kallithea/lib/celerylib/__init__.py kallithea/model/async_tasks.py
diffstat 3 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/bin/kallithea_cli_celery.py	Sat Dec 26 18:23:43 2020 +0100
+++ b/kallithea/bin/kallithea_cli_celery.py	Fri Jan 01 20:38:33 2021 +0100
@@ -17,6 +17,7 @@
 
 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 @@
     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')
 
--- a/kallithea/lib/celerylib/__init__.py	Sat Dec 26 18:23:43 2020 +0100
+++ b/kallithea/lib/celerylib/__init__.py	Fri Jan 01 20:38:33 2021 +0100
@@ -35,7 +35,7 @@
 
 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 @@
     """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:
--- a/kallithea/model/async_tasks.py	Sat Dec 26 18:23:43 2020 +0100
+++ b/kallithea/model/async_tasks.py	Fri Jan 01 20:38:33 2021 +0100
@@ -219,7 +219,7 @@
         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')