# HG changeset patch # User Mads Kiilerich # Date 2021-01-07 03:47:21 # Node ID 385d1b31f3860be16904cdccf0a7b5e7dd13b065 # Parent 516a43cbd814fc1b126ad5f60068afca6f1db1c1 celery: upgrade to Celery 5.0 ... and adjust for Click API Celery 5 has apparently no relevant API or config changes. Celery is however switching to click. run_from_argv goes away, and there is no simple way to do as before and start the worker with our Celery app but still use Celery's own command line parser. Apply hacks to make sure it still is possible to run like: kallithea-cli celery-run -c my.ini -- --help kallithea-cli celery-run -c my.ini -- --loglevel=ERROR broker_url=amqp://u:p@localhost:5672/v diff --git a/kallithea/bin/kallithea_cli_celery.py b/kallithea/bin/kallithea_cli_celery.py --- a/kallithea/bin/kallithea_cli_celery.py +++ b/kallithea/bin/kallithea_cli_celery.py @@ -12,8 +12,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import celery.bin.worker import click +from celery.bin.celery import celery as celery_command import kallithea import kallithea.bin.kallithea_cli_base as cli_base @@ -42,5 +42,12 @@ def celery_run(celery_args, config): kallithea.CELERY_APP.loader.on_worker_process_init = lambda: kallithea.config.application.make_app(config.global_conf, **config.local_conf) - cmd = celery.bin.worker.worker(kallithea.CELERY_APP) - return cmd.run_from_argv(None, command='celery-run -c CONFIG_FILE --', argv=list(celery_args)) + args = list(celery_args) + # args[0] is generally ignored when prog_name is specified, but -h *needs* it to be 'worker' ... but will also suggest that users specify 'worker' explicitly + if not args or args[0] != 'worker': + args.insert(0, 'worker') + + # inline kallithea.CELERY_APP.start in order to allow specifying prog_name + assert celery_command.params[0].name == 'app' + celery_command.params[0].default = kallithea.CELERY_APP + celery_command.main(args=args, prog_name='kallithea-cli celery-run -c CONFIG_FILE --') diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ requirements = [ "Mako >= 0.9.1, < 1.2", "Pygments >= 2.2.0, < 2.7", "Whoosh >= 2.7.1, < 2.8", - "celery >= 4.3, < 4.5, != 4.4.4", # 4.4.4 is broken due to unexpressed dependency on 'future', see https://github.com/celery/celery/pull/6146 + "celery >= 5, < 5.1", "Babel >= 1.3, < 2.9", "python-dateutil >= 2.1.0, < 2.9", "Markdown >= 2.2.1, < 3.2",