Code Monkey home page Code Monkey logo

django-celery-redis's Introduction

Django Celery Redis

This is a basic example scheduler tasks of Django , Celery with Redis

You need to install Celery and Redis in your virtual environments

pip install celery 

and

pip install redis 

Redis is a broker server

Also you need to install Redis in your machine More details about redis Redis

Insert bellow settings in your settings.py

CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = TIME_ZONE

Run your broker server

redis-server

Next run your Django server

python manage.py runserver

Next step run your Celery worker

celery -A project_name worker -l info

example:

celery -A celearyapp worker -l info

you will get task list in your console

next run your scheduler

celery -A project_name beat -l info

Example:
celery -A celeryapp beat -l info

Basically beat will call celery.py and search this his configurations I mean below code block

app.conf.beat_schedule = {
    'add-every-5-seconds': {
        'task': 'vubon',
        'schedule': 5.0,
    },
    'add-every-minute-contrab': {
        'task': 'data_checking',
        'schedule': crontab(minute=1),
    },
}

first one run every 5 seconds and second one run every 1 minute .

In your celery worker will get information what after running all commands .

By the way I added a sample app .. It was nothing .. Just query and create three class and one manager for get Data You can skip this app.

django-celery-redis's People

Contributors

vubon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.