WIP add new effects, reads, writes, to abx interface

This commit is contained in:
Nick Sweeting 2024-10-15 22:33:22 -07:00
parent 0abbc11a6b
commit 35dd5911d8
No known key found for this signature in database
6 changed files with 249 additions and 177 deletions

View file

@ -1,5 +1,8 @@
__package__ = 'archivebox.queues'
from functools import wraps
from django.utils import timezone
from django_huey import db_task, task
from huey_monitor.models import TaskModel
@ -7,6 +10,38 @@ from huey_monitor.tqdm import ProcessInfo
from .supervisor_util import get_or_create_supervisord_process
# @db_task(queue="system_tasks", context=True, schedule=1)
# def scheduler_tick():
# print('SCHEDULER TICK', timezone.now().isoformat())
# # abx.archivebox.events.on_scheduler_runloop_start(timezone.now(), machine=Machine.objects.get_current_machine())
# # abx.archivebox.events.on_scheduler_tick_start(timezone.now(), machine=Machine.objects.get_current_machine())
# scheduled_crawls = CrawlSchedule.objects.filter(is_enabled=True)
# scheduled_crawls_due = scheduled_crawls.filter(next_run_at__lte=timezone.now())
# for scheduled_crawl in scheduled_crawls_due:
# try:
# abx.archivebox.events.on_crawl_schedule_tick(scheduled_crawl)
# except Exception as e:
# abx.archivebox.events.on_crawl_schedule_failure(timezone.now(), machine=Machine.objects.get_current_machine(), error=e, schedule=scheduled_crawl)
# # abx.archivebox.events.on_scheduler_tick_end(timezone.now(), machine=Machine.objects.get_current_machine(), tasks=scheduled_tasks_due)
def db_task_with_parent(func):
"""Decorator for db_task that sets the parent task for the db_task"""
@wraps(func)
def wrapper(*args, **kwargs):
task = kwargs.get('task')
parent_task_id = kwargs.get('parent_task_id')
if task and parent_task_id:
TaskModel.objects.set_parent_task(main_task_id=parent_task_id, sub_task_id=task.id)
return func(*args, **kwargs)
return wrapper
@db_task(queue="system_tasks", context=True)
def bg_add(add_kwargs, task=None, parent_task_id=None):