How can I prevent cron from starting a new task if the previous one is still running?
Soures888 opened this issue · 2 comments
Soures888 commented
async def download_content(ctx):
await asyncio.sleep(12)
loguru.logger.debug('Job started, download content')
def run_by_seconds_interval(seconds: int):
return {i for i in range(0, 60, seconds)}
class WorkerSettings:
cron_jobs = [
cron(download_content, minute=None, second=run_by_seconds_interval(3), run_at_startup=False),
]
functions = [download_content]
How can I prevent starting a new task if the latest one hasn't finished? For example, in my production environment, I have a function that needs to run every 15 seconds. In some cases, one of these runs can take longer than 30 seconds, and I don't want this function to double-execute.
JonasKs commented
Hi,
It's documented here: https://arq-docs.helpmanual.io/#job-uniqueness