annotate python/example/rss.py @ 842:03f9657514e9

while we might not want Octave *that* much, we will never want OCAML
author Jeff Hammel <k0scist@gmail.com>
date Sun, 09 Jul 2017 15:01:16 -0700
parents 7c2dbd45c346
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
821
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 import psutil
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 PSNAME = 'python'
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 for process in psutil.process_iter():
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 try:
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 memory = process.memory_info()
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 if process.name() == PSNAME:
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 print int(memory.rss)
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 except Exception:
7c2dbd45c346 rss example program
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13 pass