good day.
i wondering why starting new process using subprocess.popen
, asking psutil.process.memory_info()
virtual memory size getting more 21 megabytes? (in script started popen
prints data read stdin passed main script)
main.py
from subprocess import popen, pipe, stdout import sys, psutil, shlex popen(shlex.split('python3 ./test.py'), stdin=pipe, stdout=pipe, stderr=stdout) proc: main_stdin = sys.stdin.read() print('writting main stdin stream:', main_stdin) proc.stdin.write(bytes(main_stdin, 'utf-8')) # "redirect" main's stdin test's stdin mem_info = psutil.process(proc.pid).memory_info() print('rss:', mem_info.rss/1048576) # bytes megabytes print('vms:', mem_info.vms/1048576) sub_stdout = proc.communicate()[0].decode('utf-8') print('reading sub stdout: ', sub_stdout)
test.py
from sys import stdin print(stdin.read())
ubuntu 14.04, python 3.4
thank you!
Comments
Post a Comment