Web-based tool for monitoring and administrating Celery clusters with real-time task tracking and worker management.
—
Core application lifecycle management for the Flower web server, including initialization, startup, configuration, and shutdown operations.
The Flower class is the central application component that manages the web server, Celery integration, and all monitoring functionality.
class Flower(tornado.web.Application):
"""
Main Flower web application class extending Tornado's Application.
Manages the web server, Celery integration, event monitoring, and worker inspection.
"""
def __init__(self, options=None, capp=None, events=None, io_loop=None, **kwargs):
"""
Initialize Flower application.
Args:
options: Tornado options namespace with configuration
capp: Celery application instance
events: Events handler instance (optional)
io_loop: Tornado IOLoop instance (optional)
**kwargs: Additional tornado.web.Application arguments
"""
def start(self):
"""
Start the Flower application server.
Starts event monitoring, binds to configured port/address,
updates worker information, and begins the IO loop.
"""
def stop(self):
"""
Stop the Flower application server.
Stops event monitoring, shuts down executors, and stops the IO loop.
"""
def update_workers(self, workername=None):
"""
Update worker information from cluster.
Args:
workername (str, optional): Specific worker to update, or None for all
Returns:
Inspection results from worker updates
"""
@property
def transport(self):
"""
Get the broker transport type.
Returns:
str: Transport driver type (e.g., 'redis', 'amqp')
"""
@property
def workers(self):
"""
Get current worker information dictionary.
Returns:
dict: Worker information keyed by worker name
"""The Flower application provides key properties for accessing cluster state and configuration.
# Core components accessible from Flower instance
flower_app.capp # Celery application instance
flower_app.events # Events monitoring instance
flower_app.inspector # Worker inspector instance
flower_app.executor # Thread pool executor
flower_app.io_loop # Tornado IOLoop instance
flower_app.options # Configuration options
flower_app.ssl_options # SSL configuration (if enabled)
flower_app.started # Boolean indicating if server is runningimport celery
from flower.app import Flower
from flower.options import default_options
# Create Celery application
celery_app = celery.Celery('myapp')
celery_app.config_from_object({
'broker_url': 'redis://localhost:6379',
'result_backend': 'redis://localhost:6379'
})
# Create Flower application
flower_app = Flower(
capp=celery_app,
options=default_options
)
# Start monitoring
flower_app.start()from tornado.options import options
from flower.app import Flower
import celery
# Configure options
options.port = 5555
options.address = '0.0.0.0'
options.debug = True
options.persistent = True
options.max_workers = 1000
# Create application with custom settings
celery_app = celery.Celery('myapp', broker='redis://localhost:6379')
flower_app = Flower(
capp=celery_app,
options=options,
cookie_secret='your-secret-key'
)
flower_app.start()from flower.app import Flower
from tornado.options import options
# Configure SSL
options.certfile = '/path/to/cert.pem'
options.keyfile = '/path/to/key.pem'
options.ca_certs = '/path/to/ca.pem'
flower_app = Flower(capp=celery_app, options=options)
flower_app.start() # Will use SSL based on certfile/keyfile optionsimport signal
import atexit
from flower.app import Flower
flower_app = Flower(capp=celery_app, options=options)
# Register cleanup handlers
atexit.register(flower_app.stop)
signal.signal(signal.SIGTERM, lambda signum, frame: flower_app.stop())
try:
flower_app.start()
except (KeyboardInterrupt, SystemExit):
flower_app.stop()Flower integrates deeply with Celery applications:
Built on Tornado web framework:
Flower uses a hybrid threading model:
Install with Tessl CLI
npx tessl i tessl/pypi-flower