Skip to content

Instantly share code, notes, and snippets.

@joshfriend
Last active August 29, 2015 14:14
Show Gist options
  • Save joshfriend/ef1253fd342adaef8f46 to your computer and use it in GitHub Desktop.
Save joshfriend/ef1253fd342adaef8f46 to your computer and use it in GitHub Desktop.
celery once test
#!/bin/bash
python tasks.py beat
#!/bin/bash
python tasks.py worker
#!/usr/bin/env python
from datetime import timedelta
from celery import Celery
from celery_once import QueueOnce
from config import Config
app = Celery(broker='redis://localhost')
app.conf.update(
CELERYBEAT_SCHEDULE = {
'say_ok': {
'task': 'tasks.say_ok',
'schedule': timedelta(seconds=10),
}
},
CELERY_IMPORTS = ['tasks'],
)
app.conf.ONCE_REDIS_URL = 'redis://localhost:6379/0'
@app.task(base=QueueOnce)
def say_ok(*args, **kwargs):
print('OK')
if __name__ == '__main__':
app.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment