cameronmaske / celery-once

Celery Once allows you to prevent multiple execution and queuing of celery tasks.
https://pypi.python.org/pypi/celery_once/
BSD 2-Clause "Simplified" License
662 stars 90 forks source link

Fix for queue once lock key not being deleted properly #92

Closed kuba-lilz closed 5 years ago

kuba-lilz commented 5 years ago

Problems: redis lacks flush

When running QueueOnce subclass task, I noticed the lock key never got deleted, event though QueueOnce.after_return was called and issued self.once_backend.clear_lock(key). After examining it turned out that I had to add self.redis.flushall() to clear_lock(key) for key to be cleared properly.

Here are my libs versions:

In [1]: import redis, celery, celery_once

In [2]: redis.__version__
Out[2]: '3.2.0'

In [3]: celery.__version__
Out[3]: '4.2.1'

In [4]: celery_once.__version__
Out[4]: '2.1.0'

In this pull request I added redis.flushall() after lock delete request, which solves the issue.

cameronmaske commented 5 years ago

Hi @kuba-lilz flushall deletes all keys of all databases, I don't think it is the solution here.

This sounds like it could be related to #93 (the keys aren't generating correctly). As I mentioned there, could you include the code snippet of the task and how it is called?

kuba-lilz commented 5 years ago

A bad implementation that tries to solve a problem that didn't exist, see discussion in #93