I have an API that returns a list of other APIs.
I need to access these APIs every 15 minutes and put the data returned into the database.
The following is what I wrote in celery_worker.py using celery and redis. But all tasks do not start.
list_of_APIs = requests.get(the_api_that_returns_list_of_APIs).json()
CELERYBEAT_SCHEDULE = {
'every-15-minute': {
'task': 'fetch_data_of_all_APIs',
'schedule': timedelta(minutes=15),
},
}
@celery.task
def access_one_API(one_API):
return requests.get(one_API).json()
@celery.task(name='fetch_data_of_all_APIs')
def fetch_data_of_all_APIs():
for one_API in list_of_APIs:
task = access_one_API.delay(one_API)
for task_id in list_of_task_id:
The function fetch_data_of_all_APIsshould run every 15 minutes, which should use several workers to run the function.access_one_API
The celery server starts in the terminal successfully, but neither fetch_data_of_all_APIs, nor access_one_API.
fetch_data_of_all_APIs, access_one_API . @celery.task, .
, - .
.