Skip to content

Commit

Permalink
Don't inherit psutil.Process from ProcessWrapper; Fix #34
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX committed Feb 16, 2015
1 parent 7e3473a commit 3fa995b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tracer/resources/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def all():
return processes


class ProcessWrapper(psutil.Process):
class ProcessWrapper(object):
"""
Wrapper for ``psutil.Process class``
Library ``psutil`` is not backward compatible from version 2.x.x to 1.x.x.
Expand All @@ -47,6 +47,11 @@ class ProcessWrapper(psutil.Process):
old version of ``psutil``.
"""

_process = None

def __init__(self, pid=None):
self._process = psutil.Process(pid)

def name(self):
return self._attr("name")

Expand All @@ -66,10 +71,13 @@ def create_time(self):
return self._attr("create_time")

def _attr(self, name):
attr = getattr(super(ProcessWrapper, self), name)
attr = getattr(self._process, name)
try: return attr()
except TypeError: return attr

def __getattr__(self, item):
return getattr(self._process, item)


class Process(ProcessWrapper):
def __eq__(self, process):
Expand Down

0 comments on commit 3fa995b

Please sign in to comment.