-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.py
53 lines (43 loc) · 1.11 KB
/
globals.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Idk what to do so i will just make a botch attempt to solve this.
from common.helpers.cache import Cache
from common.db.mysql import MySQLPool
from common.config import config
import os
# Windows compatibillity. (temp removed to make it work)
#if os.name == "nt":
import asyncio
loop = asyncio.get_event_loop()
#else:
# import uvloop
# loop = uvloop.new_event_loop()
sql = MySQLPool()
user_cache = Cache(
20,
200
)
# These are dicts as we NEVER want to drop them.
privilege_cache: dict = {}
badge_cache: dict = {}
async def connect_sql():
global sql
connected = True
await sql.connect_local(
config["db_host"],
config["db_user"],
config["db_password"],
config["db_database"],
config["db_port"],
loop
)
async def pre_cache_privs() -> None:
"""Pre-loads all of the privilege groups."""
...
# List of coros that have to be ran on startup.
STARTUP_COROS = (
connect_sql,
pre_cache_privs
)
async def startup_init() -> None:
"""Performs a series of tasks required for startup."""
for coro in STARTUP_COROS:
await coro()