OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """This file contains a class to get process information.""" | 2 """This file contains a class to get process information.""" |
3 | 3 |
4 from __future__ import unicode_literals | 4 from __future__ import unicode_literals |
5 | 5 |
6 import psutil | 6 import psutil |
7 | 7 |
8 | 8 |
9 class ProcessInfo(object): | 9 class ProcessInfo(object): |
10 """Provides information about a running process.""" | 10 """Provides information about a running process.""" |
(...skipping 22 matching lines...) Expand all Loading... |
33 def GetUsedMemory(self): | 33 def GetUsedMemory(self): |
34 """Retrieves the amount of memory used by the process. | 34 """Retrieves the amount of memory used by the process. |
35 | 35 |
36 Returns: | 36 Returns: |
37 int: amount of memory in bytes used by the process or None | 37 int: amount of memory in bytes used by the process or None |
38 if not available. | 38 if not available. |
39 """ | 39 """ |
40 try: | 40 try: |
41 memory_info = self._memory_info_function() | 41 memory_info = self._memory_info_function() |
42 except psutil.NoSuchProcess: | 42 except psutil.NoSuchProcess: |
43 return | 43 return None |
44 | 44 |
45 # Psutil will return different memory information depending on what is | 45 # Psutil will return different memory information depending on what is |
46 # available in that platform. | 46 # available in that platform. |
47 memory_data = getattr(memory_info, 'data', 0) | 47 memory_data = getattr(memory_info, 'data', 0) |
48 memory_shared = getattr(memory_info, 'shared', 0) | 48 memory_shared = getattr(memory_info, 'shared', 0) |
49 | 49 |
50 return memory_data + memory_shared | 50 return memory_data + memory_shared |
OLD | NEW |