mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
python-3.6.zip added from Github
README.cosmo contains the necessary links.
This commit is contained in:
parent
75fc601ff5
commit
0c4c56ff39
4219 changed files with 1968626 additions and 0 deletions
28
third_party/python/Lib/test/memory_watchdog.py
vendored
Normal file
28
third_party/python/Lib/test/memory_watchdog.py
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
"""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)
|
Loading…
Add table
Add a link
Reference in a new issue