From e3126d1408e005285d5cab06f4d7144461f43b11 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Mon, 6 May 2013 16:55:49 +0200 Subject: [PATCH 1/1] Ignore processes that have disappeared by themselves --- .../buildd/files/buildd-schroot-aptitude-kill | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/modules/buildd/files/buildd-schroot-aptitude-kill b/modules/buildd/files/buildd-schroot-aptitude-kill index 220e9df99..07f75c1de 100755 --- a/modules/buildd/files/buildd-schroot-aptitude-kill +++ b/modules/buildd/files/buildd-schroot-aptitude-kill @@ -30,18 +30,21 @@ total_mem = psutil.phymem_usage().total cutoff_time = 60*10 for p in psutil.process_iter(): - if p.name != 'aptitude': continue - parent = p.parent - if parent is None: continue - if parent.name != 'schroot': continue - # - rootdir = os.readlink('/proc/%d/root'%(p.pid,)) - if not rootdir.startswith('/var/lib/schroot/mount'): continue - # - used = p.get_memory_info().vms - if used < total_mem: continue - # - cputime = p.get_cpu_times().user - if cputime < cutoff_time: continue - # - p.kill() + try: + if p.name != 'aptitude': continue + parent = p.parent + if parent is None: continue + if parent.name != 'schroot': continue + # + rootdir = os.readlink('/proc/%d/root'%(p.pid,)) + if not rootdir.startswith('/var/lib/schroot/mount'): continue + # + used = p.get_memory_info().vms + if used < total_mem: continue + # + cputime = p.get_cpu_times().user + if cputime < cutoff_time: continue + # + p.kill() + except psutil.error.NoSuchProcess: + pass -- 2.20.1