Keep in mind that celery workers don’t share global states


 1. A task has a top-level variable, whose value is 1 at first

 2. After run once by celery, the value is changed to 2 

 3. When running task with celery for the second time, you will see the value is still 1 !

That’s because the the worker running for the first  time is not the one who runs for the second time.   They are different processes! 

You need to keep this in mind, and put the global states in a database or something.  

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.