(scripts): Add monitoring tools to debug script.
This commit is contained in:
@@ -1,17 +1,19 @@
|
|||||||
# !/bin/python3
|
# !/bin/python3
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import tracemalloc
|
import tracemalloc
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
import yappi
|
||||||
|
import aiomonitor
|
||||||
|
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.getcwd()))
|
sys.path.insert(0, os.path.join(os.getcwd()))
|
||||||
sys.path.insert(0, os.path.join(os.getcwd(), "src"))
|
sys.path.insert(0, os.path.join(os.getcwd(), "src"))
|
||||||
|
|
||||||
tracemalloc.start()
|
tracemalloc.start()
|
||||||
event_loop = asyncio.get_event_loop()
|
|
||||||
|
|
||||||
|
|
||||||
def loop_exception_handler(loop, context):
|
def loop_exception_handler(loop, context):
|
||||||
@@ -24,10 +26,20 @@ def loop_exception_handler(loop, context):
|
|||||||
loop.default_exception_handler(context)
|
loop.default_exception_handler(context)
|
||||||
|
|
||||||
|
|
||||||
event_loop.set_exception_handler(loop_exception_handler)
|
def main():
|
||||||
# event_loop.set_debug(enabled=True)
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.set_exception_handler(loop_exception_handler)
|
||||||
|
loop.set_debug(enabled=True)
|
||||||
|
|
||||||
|
yappi.set_clock_type("WALL")
|
||||||
|
with yappi.run():
|
||||||
|
with aiomonitor.start_monitor(loop):
|
||||||
|
from bot import _main
|
||||||
|
try:
|
||||||
|
_main()
|
||||||
|
finally:
|
||||||
|
yappi.get_func_stats().save('logs/callgrind.out.' + datetime.utcnow().isoformat(), 'CALLGRIND')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from bot import _main
|
main()
|
||||||
_main()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user