File size: 716 Bytes
b60402f
 
 
 
 
ab0a73d
b60402f
 
 
 
 
 
 
 
 
 
 
ab0a73d
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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])