You may be better to use a @task
for this and get it to re-queue itself after it executes, for example:
@app.task
def pingit(count=0):
if count < 60 * 24 * 7: # 7 days in minutes
print('Every Minute Im Called')
# Queue a new task to run in 1 minute
pingit.apply_async(kwargs={'count': count + 1}, countdown=60)
# Start the task manually
pingit.apply_async()
If you need to add positional arguments to the function, you can specify those with args
. For example, to pass a name
argument:
@app.task
def pingit(name, count=0):
if count < 60 * 24 * 7: # 7 days in minutes
print('Every Minute Im Called')
# Queue a new task to run in 1 minute
pingit.apply_async(args=[name], kwargs={'count': count + 1}, countdown=60)
# Start the task manually
pingit.apply_async(args=['MyName'])