import os
import psutil
p = psutil.Process(os.getpid())
p.get_cpu_affinity()

import numpy
p.get_cpu_affinity()

from IPython import parallel

rc = parallel.Client()
dview = rc[:]
rc.ids

dview.scatter("cpu", range(len(dview)), flatten=True)
%px print cpu

%%px
import os
import psutil

p = psutil.Process(os.getpid())
p.set_cpu_affinity([cpu])
print p.get_cpu_affinity()


%%px
import os
import psutil
from multiprocessing import cpu_count

p = psutil.Process(os.getpid())
p.set_cpu_affinity(range(cpu_count()))
print p.get_cpu_affinity()