Coder Social home page Coder Social logo

example is needed about redbeat HOT 4 CLOSED

sibson avatar sibson commented on May 24, 2024
example is needed

from redbeat.

Comments (4)

zibuyu1995 avatar zibuyu1995 commented on May 24, 2024 3

@qlygirl this is small and complete example :

config.py

#!/usr/bin/env python
# coding: utf-8

enable_utc = False
timezone = 'Asia/Shanghai'

broker_url = 'redis://:public@localhost:6379/15'

beat_scheduler = 'redbeat.RedBeatScheduler'

beat_max_loop_interval = 5

redbeat_redis_url = broker_url

redbeat_key_prefix = 'redbeat'
redbeat_schedule_key = redbeat_key_prefix + ':schedule'
redbeat_statics_key = redbeat_key_prefix + ':statics'
redbeat_lock_key = redbeat_key_prefix + ':lock'
redbeat_lock_timeout = beat_max_loop_interval * 5


beat_schedule = {
    'add-every-10-seconds': {
        'task': 'task.add_task',
        'schedule': 10.0,
        'args': (16, 16)
    },
    'add-every-5-seconds': {
        'task': 'task.test',
        'schedule': 5.0,
        'args': (16, 16)
    },
}

task.py

#!/usr/bin/env python
# coding: utf-8

import config

from celery import Celery
from datetime import datetime


app = Celery('test')
app.config_from_object(config)


@app.task
def add_task(a, b):
    print a + b
    return u'add task'


@app.task
def test():
    print datetime.now()
    return u'time test'

run

celery -A task worker -l debug
celery  beat -S redbeat.RedBeatScheduler -A task -l debug

from redbeat.

sibson avatar sibson commented on May 24, 2024 1

If you have a working Celery Beat setup, RedBeat should be enabled by following the Getting Started section. I'd like to keep RedBeat docs focused on the differences between it and schedulers provided by Celery. If there is a way to include an small example that helps RedBeat users without digressing into too much Celery config, then I'd be happy to include it.

from redbeat.

mylovelycodes avatar mylovelycodes commented on May 24, 2024

+1
hard to get start.

from redbeat.

qlygirl avatar qlygirl commented on May 24, 2024

the example is helpful, thanks!

from redbeat.

Related Issues (20)

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.