peter-hst / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Setting affinity for spawned processes #291

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. import psutil
2. p = psutil.Process(0)
3. p.set_cpu_affinity([0])

What is the expected output?

Sets an affinity for process spawned via call to: osutil.execute(...)

What do you see instead?

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python\Python27\lib\site-packages\psutil\__init__.py", line 346, in set_cpu_affinity
    return self._platform_impl.set_process_cpu_affinity(cpus)
  File "c:\Python\Python27\lib\site-packages\psutil\_psmswindows.py", line 145, in wrapper
    raise AccessDenied(self.pid, self._process_name)
psutil.error.AccessDenied: (pid=0, name='System Idle Process')

What version of psutil are you using? What Python version?
psutil 0.5
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on 
win32

On what operating system? Is it 32bit or 64bit version?
Win7 x64 SP1

Please provide any additional information below.
As described in Issue #238 this should be possible.

Original issue reported on code.google.com by maciej.l...@gmail.com on 28 Jun 2012 at 1:31

GoogleCodeExporter commented 9 years ago
Not sure what problem you are referring to here.
Is PID 0 supposed to be an alias for "set an affinity for spawned process in 
advance"?
Is that stated somewhere?
I can't see anything like that in "man sched_setaffinity" on Ubuntu 12.04.

Original comment by g.rodola on 28 Jun 2012 at 1:37

GoogleCodeExporter commented 9 years ago
Yes, it is - unfortunately I cannot find a corresponding document at the moment.

I guess it should be sufficient to call:
psutil.Process(os.getpid()) and then start subprocess.

Original comment by maciej.l...@gmail.com on 29 Jun 2012 at 5:29

GoogleCodeExporter commented 9 years ago
That would seem to be more likely.
Also, even if PID 0 has the meaning you are suggesting, psutil is not 
misbehaving in raising AccessDenied: it just means you don't have the 
permission to perform that particular action (sched_setaffinity(3) call) in 
which case you might try to use the root user and see what happens.
Closing out as invalid for now. If you find any reference to PID 0 please 
reopen.

Original comment by g.rodola on 29 Jun 2012 at 11:45