giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.32k stars 1.39k forks source link

Process.groupname doesn't work on Windows 7 #70

Closed giampaolo closed 10 years ago

giampaolo commented 10 years ago

From billiej...@gmail.com on January 26, 2010 23:35:35

>>> import psutil, os
>>> psutil.Process(os.getpid()).groupname
''
>>>

Note that for returning the empty string it takes about 10 seconds.
The slowness is caused by NetUserGetLocalGroups(), presumably because of
something related with name resolutions.
If LG_INCLUDE_INDIRECT is replaced with a "0" it returns immediately but
that doesn't solve the problem anyway.

Original issue: http://code.google.com/p/psutil/issues/detail?id=70

giampaolo commented 10 years ago

From jlo...@gmail.com on January 27, 2010 11:24:54

Summary: Process.groupname doesn't work on Windows 7
Status: Accepted

giampaolo commented 10 years ago

From billiej...@gmail.com on February 10, 2010 12:10:22

I solved the hanging problem in r475 . NetUserGetLocalGroups now returns immediately
altough an empty string is still returned.
giampaolo commented 10 years ago

From billiej...@gmail.com on February 10, 2010 12:10:56

More progresses: there was no error handling for NetUserGetLocalGroups.
I checked its returning value and used PyErr_SetFromWindowsErr() ( r476 ) and now a
WindowsError exception is raised instead of having an empty string in return.

By doing some more dubbing I discovered that the real culprit is get_proc_username()
function which returns a wrong username (in my case "Administrators", while the user
owning the process is "giampaolo") so that is why get_proc_groupname() is currently
failing.
giampaolo commented 10 years ago

From billiej...@gmail.com on February 10, 2010 12:11:16

Blockedon: 63

giampaolo commented 10 years ago

From billiej...@gmail.com on February 17, 2010 11:41:42

A comment related to this issue can be found here: 
https://code.google.com/p/psutil/issues/detail?id=14&can=1&colspec=ID%20Summary%20Type%20Opsys%20Status%20Milestone%20Opened%20Owner%20Progress#c20
giampaolo commented 10 years ago

From billiej...@gmail.com on February 17, 2010 11:46:39

We decided to remove groupname functionnality.

Status: WontFix

giampaolo commented 10 years ago

From g.rodola on March 02, 2013 03:51:04

Updated csets after the SVN -> Mercurial migration: r475 == revision 946561250dc6 r476 == revision 90e3b291077e

Blockedon: -psutil:63 psutil:63