-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmain.py
36 lines (28 loc) · 968 Bytes
/
main.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
import logging
import log_setup # type: ignore
logger: logging.Logger = logging.getLogger(__name__)
try:
import asyncio
import plugins
manager = plugins.PluginManager(["bot", "plugins", "util"])
manager.register()
async def async_main() -> None:
main_tasks = None
try:
main_tasks = await manager.load("bot.main_tasks")
await manager.load("bot.autoload")
await main_tasks.wait()
except:
logger.critical("Exception during main event loop", exc_info=True)
finally:
logger.info("Unloading all plugins")
await manager.unload_all()
logger.info("Cancelling main tasks")
if main_tasks:
main_tasks.cancel()
await main_tasks.wait_all()
logger.info("Exiting main loop")
asyncio.run(async_main())
except:
logger.critical("Exception in main", exc_info=True)
raise