Skip to content

Celery not configuring flower subcommand for user-defined preload CLI options #7894

Closed

Description

@joshuamcginnis

Per the documentation, users may add a command-line option that is passed to all sub-commands by adding a Click Option instance to user_options['preload'].

With this option, I've been able to pass an --ini cli option to the celery cli and configure my celery app from an ini file containing my application config.

However, because this new option is also passed to all sub-commands, flower fails to start as it does not recognize the new argument. Since new user-added options appear to work for other sub-commands like worker, beat, and events, I'm wondering if this is a bug in that celery is not passing this new command option down to flower?

This works for the worker, beat and events subcommands:

$ celery -A example worker --ini app.ini
app.ini

But it fails for the flower subcommand:

$ celery -A example flower --ini app.ini

The traceback:

Traceback (most recent call last):
  File "/usr/local/bin/celery", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/celery/__main__.py", line 15, in main
    sys.exit(_main())
  File "/usr/local/lib/python3.8/dist-packages/celery/bin/celery.py", line 217, in main
    return celery(auto_envvar_prefix="CELERY")
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
TypeError: flower() got an unexpected keyword argument 'ini'

dependencies:

  • celery==5.2.7
  • flower==1.2.0

example.py

from celery import Celery
from celery import signals
from click import Option

app = Celery()

ini_option = Option(('-i', '--ini'), help='ini file path to use.')

app.user_options['preload'].add(ini_option)

@signals.user_preload_options.connect
def on_preload_parsed(options, **kwargs):
    print(options['ini'])
    exit(-1)

Activity

  1. open-collective-bot commented on Nov 9, 2022

    @open-collective-bot

    Hey @joshuamcginnis 👋,
    Thank you for opening an issue. We will get back to you as soon as we can.
    Also, check out our Open Collective and consider backing us - every little helps!

    We also offer priority support for our sponsors.
    If you require immediate assistance please consider sponsoring us.

  2. added this to the 5.7.0 milestone on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions