Mercurial > kallithea
changeset 8835:385d1b31f386
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
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Thu, 07 Jan 2021 03:47:21 +0100 |
parents | 516a43cbd814 |
children | ff58aa21f9a3 |
files | kallithea/bin/kallithea_cli_celery.py setup.py |
diffstat | 2 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/bin/kallithea_cli_celery.py Thu Jan 07 03:28:37 2021 +0100 +++ b/kallithea/bin/kallithea_cli_celery.py Thu Jan 07 03:47:21 2021 +0100 @@ -12,8 +12,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -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 @@ 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 --')
--- a/setup.py Thu Jan 07 03:28:37 2021 +0100 +++ b/setup.py Thu Jan 07 03:47:21 2021 +0100 @@ -55,7 +55,7 @@ "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",