Commit 0f26522f authored by Gabriel Monnerat's avatar Gabriel Monnerat

clean up the code and add NoSuchProcess exception. This exception is raised...

clean up the code and add NoSuchProcess exception. This exception is raised when a process with a certain PID doesn't or no longer exists (zombie)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@41912 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1812a70f
......@@ -49,15 +49,17 @@ class MonitorMemory(Monitor, Process):
def get_memory_usage(self):
try:
if not hasattr(self, 'process'):
self.create_process()
elif self.process.pid != int(self.openoffice.pid()):
if not hasattr(self, 'process') or \
self.process.pid != int(self.openoffice.pid()):
self.create_process()
return sum(self.process.get_memory_info()) / (1024 * 1024)
except TypeError:
logger.debug("OpenOffice is stopped")
return 0
# convert bytes to MB
return sum(self.process.get_memory_info()) / (1024 * 1024)
except psutil.NoSuchProcess, e:
# Exception raised when a process with a certain PID doesn't or no longer
# exists (zombie).
return 0
def run(self):
"""Is called by start function. this function is responsible for
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment