Option to release lock on task acceptance
See original GitHub issueMy app watches for data changes, and then schedules a singleton task for cache regeneration. The singleton is very helpful, because i’m not queueing the same task multiple times if data changes in succession; any additional data changes will be reflected whenever the task is finally run.
However, i’m dealing with a race condition: if a task has been accepted, and data has changed after the task has accessed the database but before the task is completed (which is when the lock is released), the latest changes will not be reflected in the result- and any attempts to re-schedule the task during that time will fail because the lock still exists. i think that in my case, i need the lock to be released when the task is accepted, not when it’s finished. Sure, i will have a case where the same task is being run simultaneously, but the first task’s results are already going to be stale before the task is completed anyway.
Celery deals with these different scenarios with acks_late
, so maybe one approach is to release the lock in conjunction with task acknowledgement. Otherwise, an additional setting is desirable, so i can have the lock released during the early acknowledgment, rather than after the task is completed.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top GitHub Comments
hi @steinitzu, do we have any update on this? like having
release_lock(celery_app, task_id)
? Thanks!celery-once seems abandoned, there is no activity since 2019.