MCPcopy Index your code
hub / github.com/aws/aws-cli / _get_memory_with_ps

Function _get_memory_with_ps

awscli/testutils.py:812–825  ·  view source on GitHub ↗
(pid)

Source from the content-addressed store, hash-verified

810
811
812def _get_memory_with_ps(pid):
813 # It's probably possible to do with proc_pidinfo and ctypes on a Mac,
814 # but we'll do it the easy way with parsing ps output.
815 command_list = 'ps u -p'.split()
816 command_list.append(str(pid))
817 p = Popen(command_list, stdout=PIPE)
818 stdout = p.communicate()[0]
819 if not p.returncode == 0:
820 raise ProcessTerminatedError(str(pid))
821 else:
822 # Get the RSS from output that looks like this:
823 # USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
824 # user 47102 0.0 0.1 2437000 4496 s002 S+ 7:04PM 0:00.12 python2
825 return int(stdout.splitlines()[1].split()[5]) * 1024
826
827
828class BaseS3CLICommand(unittest.TestCase):

Callers

nothing calls this directly

Calls 2

communicateMethod · 0.45

Tested by

no test coverage detected