generated from HoloTech/discord-bot-template
36 lines
780 B
Python
Executable File
36 lines
780 B
Python
Executable File
# !/bin/python3
|
|
|
|
import sys
|
|
import os
|
|
import tracemalloc
|
|
import asyncio
|
|
|
|
|
|
sys.path.insert(0, os.path.join(os.getcwd()))
|
|
sys.path.insert(0, os.path.join(os.getcwd(), "src"))
|
|
|
|
tracemalloc.start()
|
|
|
|
|
|
def loop_exception_handler(loop, context):
|
|
print(context)
|
|
task: asyncio.Task = context.get('task', None)
|
|
if task is not None:
|
|
addendum = f"<Task name='{task.get_name()}' stack='{task.get_stack()}'>"
|
|
message = context.get('message', '')
|
|
context['message'] = ' '.join((message, addendum))
|
|
loop.default_exception_handler(context)
|
|
|
|
|
|
def main():
|
|
loop = asyncio.get_event_loop()
|
|
loop.set_exception_handler(loop_exception_handler)
|
|
loop.set_debug(enabled=True)
|
|
|
|
from bot import _main
|
|
_main()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|