steinitzu / celery-singleton

Seamlessly prevent duplicate executions of celery tasks
MIT License
237 stars 36 forks source link

Inconsistency with countdown #53

Open laxusgooee opened 1 year ago

laxusgooee commented 1 year ago

I have a task:

@shared_task(bind=True, base=Singleton, lock_expiry=10, raise_on_duplicate=True)
def encode_posts(self):
    # do some things, which might take longer than 15s, in which case call encode_posts.apply_async() else:
    encode_posts.apply_async(countdown=15)

the problem is, sometimes the code runs as I want it, i.e. runs every 15s. Other times it raises the duplicate exception.

What I want is to release the lock before calling encode_posts.apply_async(countdown=15)