Staging
v0.8.1
https://github.com/python/cpython
Revision a0ad82959652ff64c99231f457fd740b17330514 authored by Ned Deily on 15 August 2020, 03:48:14 UTC, committed by Ned Deily on 15 August 2020, 05:08:56 UTC
Note: macOS 11 is not yet released, this release of Python is not
fully supported on 11.0, and not all tests pass.
1 parent cf79cbf
Raw File
Tip revision: a0ad82959652ff64c99231f457fd740b17330514 authored by Ned Deily on 15 August 2020, 03:48:14 UTC
bpo-41100: additional fixes for testing on macOS 11 Big Sur Intel
Tip revision: a0ad829
memory_watchdog.py
"""Memory watchdog: periodically read the memory usage of the main test process
and print it out, until terminated."""
# stdin should refer to the process' /proc/<PID>/statm: we don't pass the
# process' PID to avoid a race condition in case of - unlikely - PID recycling.
# If the process crashes, reading from the /proc entry will fail with ESRCH.


import os
import sys
import time


try:
    page_size = os.sysconf('SC_PAGESIZE')
except (ValueError, AttributeError):
    try:
        page_size = os.sysconf('SC_PAGE_SIZE')
    except (ValueError, AttributeError):
        page_size = 4096

while True:
    sys.stdin.seek(0)
    statm = sys.stdin.read()
    data = int(statm.split()[5])
    sys.stdout.write(" ... process data size: {data:.1f}G\n"
                     .format(data=data * page_size / (1024 ** 3)))
    sys.stdout.flush()
    time.sleep(1)
back to top