добавил обработчик задач
All checks were successful
Deploy timelaps / deploy (push) Successful in 5s

This commit is contained in:
ack
2026-04-19 19:41:33 +03:00
parent a3df30184e
commit 4a10958445
11 changed files with 434 additions and 7 deletions

View File

View File

View File

@@ -0,0 +1,31 @@
import time
from django.core.management.base import BaseCommand
from ...services.timelapse_worker import run_one_job
class Command(BaseCommand):
help = 'Запуск обработчика очереди таймлапсов.'
def add_arguments(self, parser):
parser.add_argument('--once', action='store_true', help='Обработать только одну задачу и выйти.')
parser.add_argument(
'--sleep',
type=int,
default=5,
help='Пауза между итерациями в loop-режиме (секунды).',
)
def handle(self, *args, **options):
once = options['once']
sleep_seconds = options['sleep']
if once:
run_one_job()
return
while True:
processed = run_one_job()
if not processed:
time.sleep(sleep_seconds)