简体   繁体   中英

Tasket cmd in Python (windows)

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)```

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM