commit 8bcc61c84460c31b8e56493bbf1eb306fd5839bc Author: Damian Johnson atagar@torproject.org Date: Mon Apr 11 09:07:27 2016 -0700
Tracker could raise an unexpected CallError
Oops, stem's call() method raises a CallError (OSError subclass), not an IOError. Got the stacktrace while trying to get reconnection to work...
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner self.run() File "/home/atagar/Desktop/nyx/nyx/tracker.py", line 389, in run is_successful = self._task(self._process_pid, self._process_name) File "/home/atagar/Desktop/nyx/nyx/tracker.py", line 656, in _task total_cpu_time, uptime, memory_in_bytes, memory_in_percent = resolver(process_pid) File "/home/atagar/Desktop/nyx/nyx/tracker.py", line 213, in _resources_via_ps ps_call = system.call('ps -p {pid} -o cputime,etime,rss,%mem'.format(pid = pid)) File "/home/atagar/Desktop/nyx/stem/util/system.py", line 1080, in call raise CallError(str(exc), ' '.join(command_list), exit_status, runtime, stdout, stderr) CallError: ps -p 22439 -o cputime,etime,rss,%mem returned exit status 1 --- nyx/tracker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/nyx/tracker.py b/nyx/tracker.py index 6376584..7d567a9 100644 --- a/nyx/tracker.py +++ b/nyx/tracker.py @@ -210,7 +210,10 @@ def _resources_via_ps(pid): # TIME ELAPSED RSS %MEM # 0:04.40 37:57 18772 0.9
- ps_call = system.call('ps -p {pid} -o cputime,etime,rss,%mem'.format(pid = pid)) + try: + ps_call = system.call('ps -p {pid} -o cputime,etime,rss,%mem'.format(pid = pid)) + except OSError as exc: + raise IOError(exc)
if ps_call and len(ps_call) >= 2: stats = ps_call[1].strip().split()