Windows 7 64 - NoSuchProcess with Python 32 but no error with Python 64

73 views
Skip to first unread message

lfay

unread,
Mar 9, 2012, 12:59:02 PM3/9/12
to psutil
Hello all,

Maybe this is a duplicate of Issue 252:

I am using psutil on a Windows 7 64 bit box, but the following code
snippet:

for p in psutil.process_iter():
if p.name == 'explorer.exe':
print p.pid, p.getcwd()

prints `3944 C:\Windows\system32` in a 64 bit Python session, while it
raises NoSuchProcess in a 32 bit Python session opened at the same
time (I mean that process 3944 is still alive while writing those
lines).


When running the following code:

import psutil

results = dict()
for p in psutil.process_iter():
name = p.name
if name not in results:
results[name] = dict(pid=[p.pid], error=[])
else:
results[name]['pid'].append(p.pid)
try:
a = p.getcwd()
except psutil.NoSuchProcess:
results[name]['error'].append('NSP')
except psutil.AccessDenied:
results[name]['error'].append('AD')
else:
results[name]['error'].append(None)

def lower_cmp(x, y):
if x.lower() == y.lower():
return 0
elif x.lower() < y.lower():
return - 1
return 1

pnames = results.keys()
for pname in pnames:
if 'NSP' in results[pname]['error']:
print pname
print ' ', results[pname]['pid']
print ' ', results[pname]['error']

I get no output on my 64 bit Python, but only programs tagged as 64
bit by Windows Task Manager in my 32 bit Python (not all the tagged as
64 bit it seems, but no program tagged as 32 bit for sure).

Any help more than welcome, as using only 64 bit Python is not an
option for me...

Best regards,

LFay

Giampaolo Rodola'

unread,
Mar 9, 2012, 2:12:27 PM3/9/12
to psu...@googlegroups.com
Hi,
ideed this would seem related to issue 252.
The only difference you would get by using the fixed version from SVN is that AccessDenied would be raised instead of NoSuchProcess.
You wouldn't be able to get process cwd anyway though, so I'm not sure how much this helps.

G.

lfay

unread,
Mar 12, 2012, 4:30:02 AM3/12/12
to psutil
Hi,

Thanks for your answer. It helps to know that I will (reluctantly:
psutil was so convenient while I had to poll only 32-bit executables)
have to look for another way of doing things (the call to cwd allowed
me to tell the user on which file each process of a same executable
was opened on, which is more readable than a simple pid when choosing
which one he wants to take control of)...

Best regards,

LFay

lfay

unread,
Mar 12, 2012, 7:04:46 AM3/12/12
to psutil
Hi,

I could solve this particular problem by using wmi (http://
pypi.python.org/pypi/WMI/) when needed.

Best regards,

LFay
Reply all
Reply to author
Forward
0 new messages