-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (22 loc) · 710 Bytes
/
main.py
File metadata and controls
27 lines (22 loc) · 710 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
from asyncio import all_tasks, gather
from logging import StreamHandler, getLogger
from sys import stdout
from src.bot_instance import BotInstance
def main():
handler = StreamHandler(stream=stdout)
handler.setLevel(20)
getLogger().addHandler(handler)
client = BotInstance()
loop = client.getLoop()
try:
task = loop.create_task(client.startup())
loop.run_until_complete(task)
loop.run_until_complete(gather(*all_tasks(loop=loop)))
except (KeyboardInterrupt, RuntimeError):
print(f"Shutting down - {client.kill()}")
except Exception as ex:
print(f"Error - {ex}")
finally:
loop.close()
if __name__ == "__main__":
main()