Last active
August 7, 2019 15:52
-
-
Save meaksh/0c603a62b7189f051aa31bfba2bb8171 to your computer and use it in GitHub Desktop.
Revisions
-
meaksh renamed this gist
Aug 7, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
meaksh created this gist
Aug 7, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ import tracemalloc import threading from salt.scripts import salt_master import signal import sys stop_flag = False def print_stats(): snapshot = tracemalloc.take_snapshot() top_stats = snapshot.statistics('lineno') print("[ Top 50 ]") for stat in top_stats[:50]: print(stat) def signal_handler(sig, frame): global stop_flag stop_flag = True print_stats() print('You pressed Ctrl+C!') sys.exit(0) def timer_stats(): global stop_flag print_stats() if not stop_flag: t = threading.Timer(5.0, timer_stats) t.daemon = True t.start() signal.signal(signal.SIGINT, signal_handler) tracemalloc.start(25) timer_stats() salt_master()