[Erp5-report] r41912 gabriel - /erp5/trunk/utils/cloudooo/cloudooo/monitor/memory.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Dec 31 13:56:43 CET 2010
Author: gabriel
Date: Fri Dec 31 13:56:43 2010
New Revision: 41912
URL: http://svn.erp5.org?rev=41912&view=rev
Log:
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)
Modified:
erp5/trunk/utils/cloudooo/cloudooo/monitor/memory.py
Modified: erp5/trunk/utils/cloudooo/cloudooo/monitor/memory.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/monitor/memory.py?rev=41912&r1=41911&r2=41912&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/monitor/memory.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/monitor/memory.py [utf8] Fri Dec 31 13:56:43 2010
@@ -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
More information about the Erp5-report
mailing list