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
659 stars 91 forks source link

Set the redis lock expire time according to the ETA countdown if "default_timeout" is not given #127

Open Ed-XCF opened 3 years ago

Ed-XCF commented 3 years ago

Set the redis lock expire time according to the ETA countdown if "default_timeout" is not given Change in celery_once.tasks.py:QueueOnce.apply_async

once_timeout = (
    once_options.get('timeout')
    or self.once.get('timeout')
    or self.default_timeout
    or self.calc_timeout(options)
    or 60 * 60
)

calc_timeout code example

@staticmethod
def calc_timeout(options):
    countdown, eta = options.get("countdown"), options.get("eta")
    if countdown:
        return countdown
    elif eta:
        return localize(eta, timezone.utc)