Giampaolo Rodola' added the comment:

Ended up here by accident. For whoever bumps into this same issue, psutil 
allows to get an set CPU affinity, so you can avoid using taskset.

>>> import psutil
>>> psutil.cpu_count()
4
>>> p = psutil.Process()
>>> p.cpu_affinity()  # get
[0, 1, 2, 3]
>>> p.cpu_affinity([0])  # set; from now on, process will run on CPU #0 only
>>> p.cpu_affinity()
[0]
>>>
>>> # reset affinity against all CPUs
>>> all_cpus = list(range(psutil.cpu_count()))
>>> p.cpu_affinity(all_cpus)
>>>

----------
nosy: +giampaolo.rodola

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17038>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to