{"id":25027102,"url":"https://github.com/iamvishalaggarwal/celery-configuration","last_synced_at":"2026-04-13T20:32:12.915Z","repository":{"id":273808959,"uuid":"920950844","full_name":"iamvishalaggarwal/celery-configuration","owner":"iamvishalaggarwal","description":"Basic configuration of celery guide","archived":false,"fork":false,"pushed_at":"2025-01-23T04:08:52.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-08T14:44:37.706Z","etag":null,"topics":["celery","celery-beat","celery-result","celery-task","django","django-celery-beat","django-celery-results","guide","redis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamvishalaggarwal.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-23T04:05:48.000Z","updated_at":"2025-01-23T04:08:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"d55858bb-83bf-4369-9dd7-c4f91a9421b2","html_url":"https://github.com/iamvishalaggarwal/celery-configuration","commit_stats":null,"previous_names":["iamvishalaggarwal/celery-configuration"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iamvishalaggarwal/celery-configuration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamvishalaggarwal%2Fcelery-configuration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamvishalaggarwal%2Fcelery-configuration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamvishalaggarwal%2Fcelery-configuration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamvishalaggarwal%2Fcelery-configuration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamvishalaggarwal","download_url":"https://codeload.github.com/iamvishalaggarwal/celery-configuration/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamvishalaggarwal%2Fcelery-configuration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31770719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T20:17:16.280Z","status":"ssl_error","status_checked_at":"2026-04-13T20:17:08.216Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["celery","celery-beat","celery-result","celery-task","django","django-celery-beat","django-celery-results","guide","redis"],"created_at":"2025-02-05T18:28:32.191Z","updated_at":"2026-04-13T20:32:12.887Z","avatar_url":"https://github.com/iamvishalaggarwal.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Celery Guide\n\nCelery is a powerful task queue that allows for asynchronous task processing. This guide provides step-by-step instructions for setting up Celery with Django and includes details about scheduling tasks with Celery Beat.\n\n## What is Celery?\n\n- **Celery**: A distributed task queue for asynchronous processing.\n- **Celery Beat**: An extension for scheduling tasks.\n- **Process Overview**:\n  - A **task producer** (e.g., Django application) sends tasks to a **broker** (e.g., RabbitMQ, Redis).\n  - The broker acts as a **task queue** and forwards tasks to a **task consumer** (worker) for execution.\n  - **Celery Beat** enables task scheduling and communicates with the broker to trigger tasks at specified intervals.\n\n## Why Use Celery?\n\n- Handling third-party API calls.\n- Managing high CPU-intensive tasks.\n- Executing periodic or scheduled tasks.\n- Improving user experience with asynchronous task handling.\n\n---\n\n## Setting Up Celery\n\n### 1. Install Celery\n\nInstall Celery using pip:\n\n```bash\npip install celery\n```\n\n### 2. Configure Celery in `settings.py`\n\nAdd the following configuration in your Django project's `settings.py`:\n\n```python\nCELERY_BROKER_URL = \"redis://localhost:6379\"  # Requires Redis server\naccept_content = [\"application/json\"]\nresult_serializer = \"json\"\ntask_serializer = \"json\"\ntimezone = \"UTC\"\nresult_backend = \"django-db\"\n\n# Celery Beat settings\nCELERY_BEAT_SCHEDULER = \"django_celery_beat.schedulers:DatabaseScheduler\"\n```\n\n#### Install Redis\n\nDownload and install Redis (for Windows, use [this release](https://github.com/tporadowski/redis/releases)) and install the Redis Python client:\n\n```bash\npip install redis\n```\n\n---\n\n### 3. Install and Configure `django-celery-results` (fo storing results in DB)\n\nInstall the package:\n\n```bash\npip install django-celery-results\n```\n\nAdd it to your `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n    ...\n    \"django_celery_results\",\n]\n```\n\nRun migrations to set up the database:\n\n```bash\npython manage.py migrate\n```\n\n---\n\n### 4. Install and Configure `django-celery-beat` (for task scheduling)\n\nInstall the package:\n\n```bash\npip install django-celery-beat\n```\n\nAdd it to your `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n    ...\n    \"django_celery_beat\",\n]\n```\n\nRun migrations:\n\n```bash\npython manage.py migrate\n```\n\n---\n\n### 5. Create `celery.py` for Configuration\n\nCreate a `celery.py` file in your project's main directory and configure Celery.\n\n---\n\n### 6. Initialize Celery in `__init__.py`\n\nAdd the following code to the `__init__.py` file in your main project directory:\n\n```python\nfrom .celery import app as celery_app\n\n__all__ = (\"celery_app\",)\n```\n\n---\n\n### 7. Add Task Definitions\n\nCreate a `tasks.py` file in your app directory and define your Celery tasks.\n\n---\n\n### 8. Set Up URLs and Views\n\nDefine the views for your tasks and include the corresponding URLs in your app's `urls.py`.\n\n---\n\n### 9. Start the Django Server\n\nRun the Django development server:\n\n```bash\npython manage.py runserver\n```\n\n---\n\n### 10. Start the Celery Worker\n\nRun the Celery worker in a separate terminal:\n\n```bash\ncelery -A \u003cproject\u003e.celery worker -l info\n```\n\n#### Note for Windows Users\n\nWindows lacks native support for the prefork model. Use one of the following solutions:\n\n- **Run Celery with the Solo Pool**:\n\n  ```bash\n  celery -A \u003cproject\u003e.celery worker -l info --pool=solo\n  ```\n\n- **Run Celery with Multithreading**:\n\n  ```bash\n  celery -A \u003cproject\u003e.celery worker -l info --pool=threads\n  ```\n\n---\n\n## Verifying the Setup\n\nAfter completing the steps above, your Celery configuration should be ready. Test your tasks to ensure everything is functioning as expected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamvishalaggarwal%2Fcelery-configuration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamvishalaggarwal%2Fcelery-configuration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamvishalaggarwal%2Fcelery-configuration/lists"}