steinitzu / celery-singleton

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

retry added #9

Closed aryanbaghi closed 6 years ago

steinitzu commented 6 years ago

Thanks for contributing!

Can the lock be released in on_retry instead? http://docs.celeryproject.org/en/latest/reference/celery.app.task.html#celery.app.task.Task.on_retry

Same as the on_failure handler https://github.com/steinitzu/celery-singleton/blob/581a308a33ec3acc321b9f62526ab69dd51b7b5a/celery_singleton/singleton.py#L88

aryanbaghi commented 6 years ago

I'll try it and if it works currently I'll modify pull request. (I think you are right) Thanks

aryanbaghi commented 6 years ago

@steinitzu I've tried with on_retry and fail, because I cloud put duplicate tasks, I think retry is better place to do this, because immediately after releasing the lock retry call apply async which lock it again and there is a small possibility to putting duplicate task in queue.