From b08787de585a894417eda52d72bc416e02cf77e8 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Thu, 21 Mar 2019 21:53:02 +0900 Subject: [PATCH] fixes --- nohang.conf | 4 ++-- nohang.service | 4 ++-- nohang_notify_helper | 36 ++++++++++++++++++------------------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/nohang.conf b/nohang.conf index 09d7b2d..c478984 100644 --- a/nohang.conf +++ b/nohang.conf @@ -309,7 +309,7 @@ $ETC apache2 /// systemctl restart apache2 See also wiki.archlinux.org/index.php/Desktop_notifications Valid values are True and False. -gui_notifications = True +gui_notifications = False Enable GUI notifications about the low level of available memory. Valid values are True and False. @@ -358,7 +358,7 @@ print_mem_check_results = False 0 - печатать все проверки памяти. Неотрицательное число. -min_mem_report_interval = 10 +min_mem_report_interval = 60 Print sleep periods between memory checks. Valid values are True and False. diff --git a/nohang.service b/nohang.service index d33ead9..2c099d7 100644 --- a/nohang.service +++ b/nohang.service @@ -7,8 +7,8 @@ Documentation=man:nohang(1) https://github.com/hakavlad/nohang ExecStart=/usr/sbin/nohang --config /etc/nohang/nohang.conf Slice=nohang.slice Restart=always -MemoryMax=20M -TasksMax=10 +MemoryMax=50M +TasksMax=20 OOMScoreAdjust=-5 Nice=-20 IOSchedulingClass=1 diff --git a/nohang_notify_helper b/nohang_notify_helper index 3ac4ded..5e9b775 100755 --- a/nohang_notify_helper +++ b/nohang_notify_helper @@ -1,7 +1,4 @@ #!/usr/bin/env python3 -# -# Usage: -# ./nohang_notify_helper "title" "body" from os import listdir, path from subprocess import Popen, TimeoutExpired @@ -122,21 +119,24 @@ if list_len > 0: display_value = display_tuple[2] dbus_value = dbus_tuple[2] - with Popen([ - 'sudo', '-u', username, - 'env', - 'DISPLAY=' + display_value, - 'DBUS_SESSION_BUS_ADDRESS=' + dbus_value, - 'notify-send', - '--icon=dialog-warning', - a1, - a2 - ]) as proc: - try: - proc.wait(timeout=wait_time) - except TimeoutExpired: - proc.kill() - print('TimeoutExpired: notify user:' + username) + try: + with Popen([ + 'sudo', '-u', username, + 'env', + 'DISPLAY=' + display_value, + 'DBUS_SESSION_BUS_ADDRESS=' + dbus_value, + 'notify-send', + '--icon=dialog-warning', + a1, + a2 + ]) as proc: + try: + proc.wait(timeout=wait_time) + except TimeoutExpired: + proc.kill() + print('TimeoutExpired: notify user:' + username) + except BlockingIOError: + print('nohang_notify_helper: BlockingIOError') else: print( 'Not send GUI notification: [',