| 1166 | self.started = False |
| 1167 | |
| 1168 | def start(self): |
| 1169 | import warnings |
| 1170 | try: |
| 1171 | f = open(self.procfile, 'r') |
| 1172 | except OSError as e: |
| 1173 | logging.getLogger(__name__).warning('/proc not available for stats: %s', e, exc_info=e) |
| 1174 | sys.stderr.flush() |
| 1175 | return |
| 1176 | |
| 1177 | import subprocess |
| 1178 | with f: |
| 1179 | watchdog_script = findfile("memory_watchdog.py") |
| 1180 | self.mem_watchdog = subprocess.Popen([sys.executable, watchdog_script], |
| 1181 | stdin=f, |
| 1182 | stderr=subprocess.DEVNULL) |
| 1183 | self.started = True |
| 1184 | |
| 1185 | def stop(self): |
| 1186 | if self.started: |