GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - kennyngdev/celery-fastapi-integration: An implementation example of integrating celery with FastAPI.

BranchesTags
Open more actions menu

Latest commit

 

History

6 Commits
6 Commits

Folders and files

NameName
Last commit message
Last commit date
api
api
 
 
worker
worker
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
__init__.py
__init__.py
 
 
api.Dockerfile
api.Dockerfile
 
 
docker-compose.yml
docker-compose.yml
 
 
requirements.txt
requirements.txt
 
 
worker.Dockerfile
worker.Dockerfile
 
 

Repository files navigation

FastAPI and Celery Integration Example

Introduction

This repository provides a stripped-down demonstration of how to integrate FastAPI with Celery. To keep things straightforward and accessible, this example does not utilize Flower, differentiating it from other similar examples available on GitHub.

In this scenario, RabbitMQ serves as the message broker, while Redis functions as the result backend. We also illustrate how to incorporate async functions within Celery tasks.

(In rpc-backend branch, I also make an alternative in which rpc is used instead of redis for the result backend. Here is a brief comparison from the official celery documentation: https://docs.celeryq.dev/en/stable/getting-started/backends-and-brokers/index.html)

Setup and Installation

Using Docker

  1. To host the project, start by building the Docker images for Celery and the API, using the commands below:

    # Build the Celery image
    docker build . -f worker.Dockerfile -t worker
    
    # Build the API image
    docker build . -f api.Dockerfile -t api 
    
  2. Next, to spin up the Celery, FastAPI, RabbitMQ, and Redis containers together, use the following command:

    # Host the containers
    docker-compose up -d --build
    
  3. After initializing the Docker containers, access the Swagger UI at http://localhost:8000/docs or interact with the API directly.

How to Use

This API offers three main endpoints:

  • POST run_task: Triggers a task that takes approximately 10 seconds to complete. Upon initiating this task, a unique task ID is generated for tracking progress and retrieving results.

  • GET status: Allows users to track the status of a specific task using its ID.

  • GET result: Retrieves the result of a completed task using its ID.

Support

If you find this project useful, please consider giving the repository a star!

For any queries or feedback, reach out to the author, Kenny Ng, at [email protected].

About

An implementation example of integrating celery with FastAPI.

Topics

celeryfastapifastapi-templatepythonrabbitmqredis

Resources

Readme
CC0-1.0 license
Activity

Stars

1 star

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.