From 522d1507ee2f244daee90bca0b4dc46276f1c190 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Fri, 11 Jan 2019 02:04:40 +0900 Subject: [PATCH] fix find_victim --- nohang | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/nohang b/nohang index ba41d73..afecb1d 100755 --- a/nohang +++ b/nohang @@ -578,51 +578,62 @@ def find_victim_and_send_signal(signal): except FileNotFoundError: print('The victim died in the search process') - + # update stat_dict key = 'The victim died in the search process' if key not in stat_dict: stat_dict.update({key: 1}) else: new_value = stat_dict[key] + 1 - stat_dict.update({key: new_value}) - + stat_dict.update({key: new_value} + for key in stat_dict: + stats_msg += '\n - {}: {}'.format(key, stat_dict[key]) + print(stats_msg) return None + except ProcessLookupError: print('The victim died in the search process') - + # update stat_dict key = 'The victim died in the search process' if key not in stat_dict: stat_dict.update({key: 1}) else: new_value = stat_dict[key] + 1 - stat_dict.update({key: new_value}) - + stat_dict.update({key: new_value} + for key in stat_dict: + stats_msg += '\n - {}: {}'.format(key, stat_dict[key]) + print(stats_msg) return None + except IndexError: print('The victim died in the search process') - + # update stat_dict key = 'The victim died in the search process' if key not in stat_dict: stat_dict.update({key: 1}) else: new_value = stat_dict[key] + 1 - stat_dict.update({key: new_value}) - + stat_dict.update({key: new_value} + for key in stat_dict: + stats_msg += '\n - {}: {}'.format(key, stat_dict[key]) + print(stats_msg) return None + except ValueError: print('The victim died in the search process') - + # update stat_dict key = 'The victim died in the search process' if key not in stat_dict: stat_dict.update({key: 1}) else: new_value = stat_dict[key] + 1 - stat_dict.update({key: new_value}) - + stat_dict.update({key: new_value} + for key in stat_dict: + stats_msg += '\n - {}: {}'.format(key, stat_dict[key]) + print(stats_msg) return None len_vm = len(str(vm_size)) @@ -704,6 +715,10 @@ def find_victim_and_send_signal(signal): new_value = stat_dict[key] + 1 stat_dict.update({key: new_value}) + for key in stat_dict: + stats_msg += '\n - {}: {}'.format(key, stat_dict[key]) + + print(mem_info) print(etc_info) @@ -734,7 +749,7 @@ def find_victim_and_send_signal(signal): response_time = time() - time0 send_result = 'no such process; response time: {} ms'.format( round(response_time * 1000)) - + # update stat_dict key = 'The victim died in the search process' if key not in stat_dict: @@ -742,7 +757,7 @@ def find_victim_and_send_signal(signal): else: new_value = stat_dict[key] + 1 stat_dict.update({key: new_value}) - + except ProcessLookupError: response_time = time() - time0 send_result = 'no such process; response time: {} ms'.format( @@ -757,10 +772,6 @@ def find_victim_and_send_signal(signal): new_value = stat_dict[key] + 1 stat_dict.update({key: new_value}) - - - - preventing_oom_message = '{}' \ '\n\033[4mImplement a corrective action:\033[0m\n ' \ 'Sending \033[4m{}\033[0m to the victim; {}'.format(