1

Hi all I am just wondering how I can use Taskset command in windows?

Here's Part of code which is written in python and I am running it on windows it is giving error as taskset' is not recognized as an internal or external command

here's code below :-

    event_list = df.to_records(index=False)
    event_list  = list(event_list)
    os.system("taskset -p 0xff %d" % os.getpid())
    p = Pool(processes=60)
    p.starmap(calc_hazard,event_list)

print(time.time()-t_initial)```
  • This should help : https://stackoverflow.com/questions/10829974/taskset-equivalent-in-windows – Marius ROBERT May 30 '22 at 11:23
  • actually i tried it but i am not able to understand how to run it, can you please explain me ? thank you so much –  May 30 '22 at 11:26
  • I didn't understood it neither, I just found it and it seems to be an answer to your problem – Marius ROBERT May 30 '22 at 11:27
  • 1
    Does this answer your question? [taskset equivalent in windows](https://stackoverflow.com/questions/10829974/taskset-equivalent-in-windows) – Marius ROBERT May 30 '22 at 11:28
  • No buddy :( lets see i am trying to find out –  May 30 '22 at 12:00
  • If you have powershell, [this](https://serverfault.com/questions/1083845/what-is-equivalent-of-taskset-on-powershell) can help you – Veysel Olgun Jul 21 '22 at 00:07

1 Answers1

1

You can use the psutil library which implements the taskset command. For example:

p = psutil.Process(pid)
p.cpu_affinity(cpus)

where cpus is a list of integers specifying the new CPUs affinity. The documentation is here.

lfamorim
  • 11
  • 2