Created
August 8, 2017 17:00
-
-
Save LowerDeez/b72ad6e1896b2716e6af1e4a78f6f1be to your computer and use it in GitHub Desktop.
Django. Periodic task in Celery + RebbitMQ
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
from celery.schedules import crontab | |
from services import crawlers | |
from celery.task.base import periodic_task | |
from celery.utils.log import get_task_logger | |
logger = get_task_logger(__name__) | |
@periodic_task(run_every=(crontab(hour="*", minute="*", day_of_week="*"))) | |
def update_githab(): | |
# logger.info("Start task") | |
print('Task !!!!!!!!!!!!!!!!!') | |
crawlers.GithubCrawler().run() | |
# logger.info("Task finished") | |
""" | |
Чтобы заработало запустить в разных окнах: | |
1) celery -A blog worker -l info | |
2) celery -A blog beat -l info | |
+ по желанию | |
3) celery -A blog flower | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment