annotate python/example/rss.py @ 824:16200adbd4f0

work around exit code for no changes
author Jeff Hammel <k0scist@gmail.com>
date Tue, 07 Feb 2017 10:28:00 -0800
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