Closed GoogleCodeExporter closed 8 years ago
Original comment by g.rodola
on 12 Nov 2010 at 9:40
Some references:
Windows
http://stackoverflow.com/questions/1393006/how-to-get-the-cpu-usage-per-thread-o
n-windows-win32
http://www.codeproject.com/KB/system/processescpuusage.aspx
Linux (possibly BSD if the C code works)
http://108leaves.com/codediary/?p=1
OS X
http://stackoverflow.com/questions/1455320/how-to-get-the-cpu-usage-per-thread-o
n-mac-osx
Original comment by jlo...@gmail.com
on 12 Nov 2010 at 1:53
Original comment by jlo...@gmail.com
on 12 Nov 2010 at 8:07
thank you for reply :)
.
.
Original comment by zip...@gmail.com
on 14 Nov 2010 at 9:45
[deleted comment]
We should first have a "get_threads()" function returning a list of objects
(I'd say a namedtuple) including at least thread id, user and kernel times
information, and possibly also other information.
From there, adding a get_threads_percent() returning a namedtuple including
thread id and percentage usage, but I'm not sure I like this kind of API (for
now at least).
I'd say we better focus on implementing get_threads() first, and change the
subject/discussion of this issue in accordance.
get_threads_percent() is something we might think about later.
Note: get_threads() should deprecate current get_num_threads().
Original comment by g.rodola
on 14 Nov 2010 at 11:59
how to Enum threads in a process?
http://www.tech-archive.net/Archive/VC/microsoft.public.vc.language/2004-05/0509
.html
it seems that ToolHelp32 in the Kernel32.dll which have some functions like
CreateToolhelp32Snapshot+Thread32First+Thread32Next
others said it can enum threads in a process
there is also some c++ code to enum threads in above site...
but it is hard to use c++ or dll with python...
Original comment by zip...@gmail.com
on 16 Nov 2010 at 8:03
Yes, we are already using CreateToolhelp32Snapshot, Thread32First and
Thread32Next currently to get the number of threads per-process.
I still haven't looked into it properly, but retrieving other information from
threads on Windows seems quite straightforward.
Original comment by g.rodola
on 16 Nov 2010 at 9:13
Implemented on Linux in r821.
A new Process.get_threads() method is available returning a namedtuple as such:
>>> p = psutil.Process(os.getpid())
>>> p.get_threads()
[thread(id=3318, user_time=0.01, system_time=0.01)]
Original comment by g.rodola
on 16 Nov 2010 at 8:43
Implemented on Windows in r822.
Original comment by g.rodola
on 16 Nov 2010 at 9:54
Original comment by g.rodola
on 19 Nov 2010 at 10:21
Implemented for FreeBSD in r827 thanks to:
http://fxr.googlebit.com/source/usr.bin/procstat/procstat_threads.c?v=8-CURRENT
It turns out procstat utility (wasn't aware of it) has a lot of useful and well
written code we can borrow (e.g. process files/connections which we can
reimplement in C).
Original comment by g.rodola
on 20 Nov 2010 at 7:53
nice update!...
it is the best python module to get process infomatinon i have found...quickly
and fully...
.
.
.
Original comment by zip...@gmail.com
on 22 Nov 2010 at 4:04
Implemented for OSX in r922.
It seems we cannot determine the thread ids, so I used an incremental bogus
value as a replacement.
Original comment by g.rodola
on 17 Feb 2011 at 2:02
Original comment by g.rodola
on 20 Mar 2011 at 9:55
[deleted comment]
Updated csets after the SVN -> Mercurial migration:
r821 == revision aa0b3d808dc8
r822 == revision bd431637453d
r827 == revision b870cf4e47e6
r922 == revision e563f0bf792e
Original comment by g.rodola
on 2 Mar 2013 at 11:56
Original issue reported on code.google.com by
zip...@gmail.com
on 12 Nov 2010 at 8:30