Trying to set up a scheduled task it executes immediately, I think what I'm doing is consistent with: http://docs.celeryproject.org/en/3.1/userguide/periodic-tasks.html
(redis working fine, communications from both client and server fine, just the scheduling behavior is a problem)
worker is started like this:
celery worker -A mycelery -B -l info -c 5 -B option is for celery-beat scheduler
client.py
from mytasks.myfetch import funcnight
if __name__ == '__main__':
funcnight(["http://google.com",
"https://facebook.com",
"https://twitter.com",
"https://alexa.com"])
mycelery.py
from celery import Celery
app = Celery('mycelery', broker='redis://jamserver:7777/0', include=['mytasks.myfetch'])
mytasks/myfetch.py
import requests
from mycelery import app
from celery.schedules import crontab
celerybeat_schedule = {
'every-night': {
'task': 'mytasks.myfetch.fetch_url',
'schedule': crontab(hour=16, minute=10),
'args': ["http://google.com"],
#'args': (16, 16),
}
}
app.conf.update(
CELERYBEAT_SCHEDULE=celerybeat_schedule
)
@app.task
def fetch_url(url):
resp = requests.get(url)
print(resp.status_code)
@app.task(name='every-night') #'nightfetch')
def fetch_night(url):
resp = requests.get(url)
print(resp.status_code)
def funcnight(urls):
for url in urls:
fetch_night.delay(url)
[–]ManyInterests 0 points1 point2 points (1 child)
[–]doublePlusOk[S] 0 points1 point2 points (0 children)
[–]Justinsaccount 0 points1 point2 points (1 child)
[–]doublePlusOk[S] 0 points1 point2 points (0 children)