Improve signals handling at exit

This commit is contained in:
Alexey Avramov 2020-06-12 10:17:37 +09:00
parent 206c4e4b06
commit d457aaea38

View File

@ -799,14 +799,19 @@ def signal_handler(signum, frame):
log('Got the {} signal '.format( log('Got the {} signal '.format(
sig_dict[signum])) sig_dict[signum]))
fd['mi'].close() if len(fd) > 0:
for f in fd:
fd[f].close()
print_stat_dict() print_stat_dict()
m1 = monotonic()
pt1 = process_time() m = monotonic() - m0
ab = pt1 - pt0 pt = process_time() - pt0
perc = (pt1 - pt0) / (m1 - m0) * 100 pt_percent = pt / m * 100
log('CPU time since monitoring has started: {} ({}%); exit.'.format( log('CPU time since monitoring has started: {} ({}%); exit.'.format(
format_time(ab), round(perc, 3))) format_time(pt), round(pt_percent, 3)))
exit() exit()