2

Right now I have a @sharedtask that follows the following code exactly: http://docs.celeryproject.org/en/latest/tutorials/task-cookbook.html#id1

And the following scheduler settings:

CELERYBEAT_SCHEDULE = {
    'indefinite-task': {
        'task': 'app.tasks.indefinite_task',
        'schedule': timedelta(seconds=1),
    },
}

But my two of my workers seem to be running the task more than once, presumably because of a worker having concurrent threads? How can I ensure that the task is only run once by a single thread on a single worker?

Example of what I am seeing in the shell:

11:00:43 worker.1 | [2015-05-05 15:00:43,444: DEBUG/Worker-1] app.tasks.indefinite_task[b8b0445c-91e6-4652-bd75-4c609149161f]: Acquiring lock
11:00:43 worker.1 | [2015-05-05 15:00:43,444: DEBUG/Worker-2] app.tasks.indefinite_task[b8b0445c-91e6-4652-bd75-4c609149161f]: Acquiring lock

Edit: I'm using a Procfile with heroku.

1 Answer 1

0

Perhaps you want to run the python script in it's own worker process.

Ex:

worker: python indefinite_task.py

This ensures that only one task is run for that worker.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.