Changeset - 385d1b31f386
[Not reviewed]
default
0 2 0
Mads Kiilerich (mads) - 5 years ago 2021-01-07 03:47:21
mads@kiilerich.com
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
2 files changed with 11 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_cli_celery.py
Show inline comments
 
@@ -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 @@ 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 --')
setup.py
Show inline comments
 
@@ -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",
0 comments (0 inline, 0 general)