MCPcopy Index your code
hub / github.com/python/cpython / _MemoryWatchdog

Class _MemoryWatchdog

Lib/test/support/__init__.py:1238–1266  ·  view source on GitHub ↗

An object which periodically watches the process' memory consumption and prints it out.

Source from the content-addressed store, hash-verified

1236
1237
1238class _MemoryWatchdog:
1239 """An object which periodically watches the process' memory consumption
1240 and prints it out.
1241 """
1242
1243 def __init__(self):
1244 self.procfile = '/proc/{pid}/statm'.format(pid=os.getpid())
1245 self.started = False
1246
1247 def start(self):
1248 try:
1249 f = open(self.procfile, 'r')
1250 except OSError as e:
1251 logging.getLogger(__name__).warning('/proc not available for stats: %s', e, exc_info=e)
1252 sys.stderr.flush()
1253 return
1254
1255 import subprocess
1256 with f:
1257 watchdog_script = findfile("memory_watchdog.py")
1258 self.mem_watchdog = subprocess.Popen([sys.executable, watchdog_script],
1259 stdin=f,
1260 stderr=subprocess.DEVNULL)
1261 self.started = True
1262
1263 def stop(self):
1264 if self.started:
1265 self.mem_watchdog.terminate()
1266 self.mem_watchdog.wait()
1267
1268
1269def bigmemtest(size, memuse, dry_run=True):

Callers 1

wrapperFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…