eu-scrapper / app /api /scraper /services /background_tasks.py
brestok's picture
init
ab0a73d
raw
history blame contribute delete
716 Bytes
import asyncio
from apscheduler.schedulers.asyncio import AsyncIOScheduler # type: ignore
from apscheduler.triggers.cron import CronTrigger # type: ignore
from .parser import EquinixParser, AmazonParser, LinkedinParser
async def schedule_update():
"""
Schedule periodic statistics generation jobs.
"""
scheduler = AsyncIOScheduler()
scheduler.add_job(run_update, CronTrigger(day_of_week="sun", hour=23, minute=0))
scheduler.start()
while True:
await asyncio.sleep(3600)
async def run_update():
"""
Run periodic update tasks.
"""
parsers = [EquinixParser(), AmazonParser(), LinkedinParser()]
await asyncio.gather(*[parser.run() for parser in parsers])