Skip to content

Conversation

Copy link

Copilot AI commented Aug 5, 2025

This PR adds a comprehensive Celery example to demonstrate how Hot Module Reload (HMR) works with Celery workers and task definitions. The example showcases the power of HMR by allowing developers to modify task implementations and see changes take effect immediately without restarting the Celery worker process.

What's Added

The new examples/celery/ directory contains a complete, self-contained Celery application with:

  • app.py: Celery application configuration using in-memory broker for easy demonstration
  • tasks.py: Four example tasks showing different HMR scenarios:
    • Simple arithmetic operations
    • Data processing with complex logic
    • Long-running tasks for testing HMR during execution
    • Failing tasks that can be "fixed" with HMR
  • worker.py: Main entry point that integrates Celery worker with HMR lifecycle management
  • sender.py: Test script to send tasks and verify HMR functionality
  • utils.py: Logging utilities that can also be hot-reloaded
  • README.md: Comprehensive documentation with step-by-step instructions
  • pyproject.toml: Project dependencies

Key Features Demonstrated

  1. Hot-reloadable task definitions: Modify task logic in tasks.py and see changes immediately
  2. Worker lifecycle management: Proper integration between HMR and Celery worker threads
  3. Real-time development workflow: Send tasks while modifying code to see live updates
  4. Error recovery: Fix broken tasks without restarting the worker

Usage Example

# Start the worker with HMR
hmr worker.py

# In another terminal, send test tasks
python sender.py

# Modify tasks.py and run sender.py again to see HMR in action

This example follows the same patterns as the existing Flask and FastAPI examples, providing developers with a familiar structure while showcasing HMR's capabilities in a distributed task processing context. The use of an in-memory broker makes it easy to run without external dependencies, perfect for development and demonstration purposes.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
@hyperlint-ai-deprecated
Copy link

PR Change Summary

Added a new Celery example to demonstrate HMR capabilities with Celery workers and tasks.

  • Created a complete Celery example with multiple Python files for HMR scenarios.
  • Implemented hot-reloadable tasks and worker lifecycle management.
  • Added comprehensive documentation with step-by-step instructions and troubleshooting.

Added Files

  • examples/celery/README.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
Copilot AI changed the title [WIP] 新增一个 celery 的 example,参考 @promplate/hmr @promplate/pyth-on-line/files/packages/hmr Add Celery example demonstrating HMR integration Aug 5, 2025
Copilot AI requested a review from CNSeniorious000 August 5, 2025 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants