Last active
August 29, 2015 14:14
-
-
Save joshfriend/ef1253fd342adaef8f46 to your computer and use it in GitHub Desktop.
celery once test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
python tasks.py beat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
python tasks.py worker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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