CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-flower

Web-based tool for monitoring and administrating Celery clusters with real-time task tracking and worker management.

Pending
Overview
Eval results
Files

application.mddocs/

Application Management

Core application lifecycle management for the Flower web server, including initialization, startup, configuration, and shutdown operations.

Capabilities

Main Application Class

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
        """

Application Properties

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 running

Usage Examples

Basic Application Setup

import 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()

Custom Configuration

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()

SSL Configuration

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 options

Graceful Shutdown

import 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()

Integration Points

Celery Integration

Flower integrates deeply with Celery applications:

  • Automatic task registration discovery
  • Event monitoring from Celery's event system
  • Worker inspection using Celery's remote control
  • Broker connection sharing

Tornado Integration

Built on Tornado web framework:

  • Asynchronous request handling
  • WebSocket support for real-time updates
  • Static file serving for web interface
  • Template rendering system

Threading Model

Flower uses a hybrid threading model:

  • Main thread runs Tornado's IOLoop
  • Background thread for event capture
  • Thread pool executor for blocking operations
  • Asynchronous operations for I/O tasks

Install with Tessl CLI

npx tessl i tessl/pypi-flower

docs

application.md

authentication.md

broker.md

command-line.md

events.md

index.md

rest-api.md

tasks.md

utilities.md

web-interface.md

workers.md

tile.json