Skip to content

Instantly share code, notes, and snippets.

@ThrowsException
Created August 26, 2015 21:52
Show Gist options
  • Save ThrowsException/f65981f2e15bc12c2930 to your computer and use it in GitHub Desktop.
Save ThrowsException/f65981f2e15bc12c2930 to your computer and use it in GitHub Desktop.
Simple celery app with mongodb
from celery import Celery
CELERY_BROKER_URL = 'redis://127.0.0.1:6379'
app = Celery('tasks', broker=CELERY_BROKER_URL)
app.conf.update(
CELERY_TASK_SERIALIZER='json',
CELERY_ACCEPT_CONTENT=['json'],
CELERY_RESULT_SERIALIZER='json',
CELERY_MONGODB_SCHEDULER_DB = "celery",
CELERY_MONGODB_SCHEDULER_COLLECTION = "schedules",
CELERY_MONGODB_SCHEDULER_URL = "mongodb://10.0.2.2",
CELERY_BROKER_URL = 'redis://127.0.0.1:6379',
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379'
)
@app.task
def add():
print "yay"
return "yay"
{
"_id" : ObjectId("533c5b29b45a2092bffceb13"),
"name" : "celery_mongo.add",
"task" : "celery_mongo.add",
"enabled" : true,
"interval" : {
"every" : 10,
"period" : "seconds"
}
}
@zakird
Copy link

zakird commented Aug 27, 2015

What's in the logs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment