ANN: psutil (python process utilities) 0.2.1 released

Giampaolo Rodolà g.rodola at gmail.com
Sun Mar 20 17:40:20 EDT 2011


Hi,
I'm pleased to announce the 0.2.1 release of psutil:
http://code.google.com/p/psutil

=== About ===

psutil is a module providing an interface for retrieving information
on running processes and system utilization (CPU, memory) in a
portable way by using Python, implementing many functionalities
offered by command line tools like ps, top, kill, lsof and netstat.

It currently supports Linux, Windows, OS X and FreeBSD both 32-bit and
64-bit with Python versions from 2.4 to 3.2 by using a unique code
base.


=== Major enhancements ===

* per-process I/O counters
* per-process wait() (wait for process to terminate and return its exit code)
* per-process get_threads() returning information (id, user and kernel
times) about threads opened by process.
* per-process real, effective and saved user and group ids.
* per-process get and set niceness (priority)
* per-process status
* per-process I/O nice (priority) - Linux only
* psutil.Popen class which tidies up subprocess.Popen and
psutil.Process in a unique interface.
* system boot time

=== New features by example ===

>>> p = psutil.Process(7055)
>>> p.name
'python'
>>>
>>> p.status
0
>>> str(p.status)
'running'
>>>
>>> p.uids
user(real=1000, effective=1000, saved=1000)
>>> p.gids
group(real=1000, effective=1000, saved=1000)
>>>
>>> p.nice
0
>>> p.nice = 10  # set/change process priority
>>> p.nice
10
>>>
>>> p.get_ionice()
ionice(ioclass=0, value=0)
>>> p.set_ionice(psutil.IOPRIO_CLASS_IDLE)  # change process I/O priority
>>> p.get_ionice()
ionice(ioclass=3, value=0)
>>>
>>> p.get_io_counters()
io(read_count=478001, write_count=59371, read_bytes=700416, write_bytes=69632)
>>>
>>> p.get_threads()
[thread(id=5234, user_time=22.5, system_time=9.2891),
 thread(id=5235, user_time=0.0, system_time=0.0),
 thread(id=5236, user_time=0.0, system_time=0.0),
 thread(id=5237, user_time=0.0707, system_time=1.2)]
>>>
>>> p.terminate()
>>> p.wait(timeout=3)
0
>>>


= new subprocess interface =

>>> import psutil
>>> from subprocess import PIPE
>>> p = psutil.Popen(["/usr/bin/python", "-c", "print 'hi'"], stdout=PIPE)
>>> p.name
'python'
>>> p.uids
user(real=1000, effective=1000, saved=1000)
>>> p.username
'giampaolo'
>>> p.communicate()
('hi\n', None)
>>> p.terminate()
>>> p.wait(timeout=2)
0
>>>


=== Links ===

* Home page: http://code.google.com/p/psutil
* Mailing list: http://groups.google.com/group/psutil/topics
* Source tarball: http://psutil.googlecode.com/files/psutil-0.2.1.tar.gz
* Api Reference: http://code.google.com/p/psutil/wiki/Documentation



--- Giampaolo Rodola'

http://code.google.com/p/pyftpdlib
http://code.google.com/p/psutil/



More information about the Python-list mailing list