os.times() for other process

Christian Schmidt surname.forename at aifb.uni-karlsruhe.de
Wed Jan 15 10:16:21 CET 2003

Thanks Colin,
> A method I have used in the past (although not elegant, it is easy) is to
> use "pslist" from the
> pstools kit (www.sysinternals.com). For example:
> import os
> def ProcTimes(pid):
>     text = os.popen(r'c:\pstools\pslist '+str(pid),'r').read()
>     info = text.split('\n')[-2]
>     items = info.split()
>     return {'User': items[-3], 'Kernel': items[-2], 'Elapsed': items[-1]}
> I hope this helps.
Yes, this helps. But only on Windows...
On Linux I can parse /proc/pid/stat, but I was hoping that I could access
these values without parsing.

More information about the Python-list mailing list