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)
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...
On Friday, March 9, 2012 6:59:02 PM UTC+1, lfay wrote:
> 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)
> 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
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.
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
On 9 mar, 20:12, Giampaolo Rodola' <g.rod...@gmail.com> wrote:
> On Friday, March 9, 2012 6:59:02 PM UTC+1, lfay wrote:
> > 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)
> > 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
> 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.
> 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
> On 9 mar, 20:12, Giampaolo Rodola' <g.rod...@gmail.com> wrote:
> > On Friday, March 9, 2012 6:59:02 PM UTC+1, lfay wrote:
> > > 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)
> > > 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
> > 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.