diff options
author | John Kacur <jkacur@redhat.com> | 2017-09-13 00:39:08 +0100 |
---|---|---|
committer | John Kacur <jkacur@redhat.com> | 2017-09-13 01:08:20 +0100 |
commit | d02bf76417b0225c0176b9156b127111c7e649f5 (patch) | |
tree | 87f69658903b0f286977048b7f18901ad82525d4 | |
parent | 876beba81c6b213e0fe4755409142cddb78e344d (diff) | |
download | tuna-d02bf76417b0225c0176b9156b127111c7e649f5.tar.gz |
tuna: isolate_cpus - exit with a message instead of a traceback
isolate_cpus can create a traceback if passed an illegal cpuset
If this happens, exit with a message instead of a traceback
Signed-off-by: John Kacur <jkacur@redhat.com>
-rwxr-xr-x | tuna/tuna.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tuna/tuna.py b/tuna/tuna.py index 562c7fc..213bbf6 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -343,6 +343,7 @@ def parse_irq_affinity_filename(filename, nr_cpus): def isolate_cpus(cpus, nr_cpus): + fname = sys._getframe( ).f_code.co_name # Function name ps = procfs.pidstats() ps.reload_threads() previous_pid_affinities = {} @@ -354,6 +355,9 @@ def isolate_cpus(cpus, nr_cpus): except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError if e[0] == errno.ESRCH: continue + elif e[0] == errno.EINVAL: + print >> sys.stderr, "Function:", fname, ",", e.strerror + sys.exit(2) raise e if set(affinity).intersection(set(cpus)): previous_pid_affinities[pid] = copy.copy(affinity) @@ -363,6 +367,9 @@ def isolate_cpus(cpus, nr_cpus): except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError if e[0] == errno.ESRCH: continue + elif e[0] == errno.EINVAL: + print >> sys.stderr, "Function:", fname, ",", e.strerror + sys.exit(2) raise e if not ps[pid].has_key("threads"): @@ -376,6 +383,9 @@ def isolate_cpus(cpus, nr_cpus): except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError if e[0] == errno.ESRCH: continue + elif e[0] == errno.EINVAL: + print >> sys.stderr, "Function:", fname, ",", e.strerror + sys.exit(2) raise e if set(affinity).intersection(set(cpus)): previous_pid_affinities[tid] = copy.copy(affinity) @@ -385,6 +395,9 @@ def isolate_cpus(cpus, nr_cpus): except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError if e[0] == errno.ESRCH: continue + elif e[0] == errno.EINVAL: + print >> sys.stderr, "Function:", fname, ",", e.strerror + sys.exit(2) raise e del ps |