From 7c8c2c6b422c7c85888768a31c4700aae64387fe Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Fri, 11 Nov 2022 16:51:34 +0300 Subject: [PATCH] [~] Refactor --- dotfiles/.local/bin/commands | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dotfiles/.local/bin/commands b/dotfiles/.local/bin/commands index 351edf5..c88e976 100755 --- a/dotfiles/.local/bin/commands +++ b/dotfiles/.local/bin/commands @@ -175,6 +175,12 @@ def eternal_oom(argv): default=None, type=int, ) + parser.add_option( + '--period', + dest='period', + default=None, + type=float, + ) parser.add_option( '--memory_limit', dest='memory_limit', @@ -197,6 +203,8 @@ def eternal_oom(argv): self_pid = os.getpid() + if options.period is None: + options.period = 1 if options.memory_limit is None: options.memory_limit = 3 * 1024 * 1024 if options.cpu_limit is None: @@ -214,6 +222,8 @@ def eternal_oom(argv): and options.cpu_limit > 0.2 * os.cpu_count() and \ options.cpu_limit < os.cpu_count() * 0.8 + assert options.period >= 1 + assert options.cpu_wait >= 10 assert options.mean_size >= 16 @@ -593,7 +603,7 @@ def eternal_oom(argv): [options.cpu_limit, oom_mean_cpu(), t11['total_cpu']], ]) oom_kill(t11['by_cpu']['PID_x'][0]) - time.sleep(1) + time.sleep(options.period) def resilient_vlc(stream=None): if stream is None: