-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathrun_scheduler.py
More file actions
30 lines (22 loc) · 860 Bytes
/
Copy pathrun_scheduler.py
File metadata and controls
30 lines (22 loc) · 860 Bytes
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
28
29
30
import asyncio
import aiohttp
from hoyo_buddy.config import CONFIG
from hoyo_buddy.db.pgsql import Database
from hoyo_buddy.l10n import translator
from hoyo_buddy.scheduler.main import Scheduler
from hoyo_buddy.utils import setup_async_event_loop, setup_logging, setup_sentry, wrap_task_factory
async def main() -> None:
wrap_task_factory()
setup_logging("logs/scheduler.log")
setup_async_event_loop()
setup_sentry(CONFIG.scheduler_sentry_dsn)
async with Database(), translator, aiohttp.ClientSession() as session:
scheduler = Scheduler(session)
scheduler.start()
try:
while True: # ruff:ignore[async-busy-wait]
await asyncio.sleep(1)
except (KeyboardInterrupt, asyncio.CancelledError):
scheduler.shutdown()
if __name__ == "__main__":
asyncio.run(main())