Reputation: 2216
From the answer to my old question, I gone through this and some more from google. But I did not understand, how can I cpulimit
for a python script.
Followings are my try:
cpulimit --limit 20 --exe ./read_heavy_csv.py
cpulimit --limit 20 --exe "python read_heavy_csv.py"
cpulimit -P ./read_heavy_csv.py -l 20
and some more...
But in each case getting warning :
Warning: no target process found. Waiting for it...
I could not find any documentation to explain running a python script with cpulimit
. I also gone through these too but did not get any clue
Upvotes: 1
Views: 4097
Reputation: 369164
Instead of executing a program, cpulimit
limits the cpu usage of running process. You need to run the program separately.
Run the program normally:
python read_heavy_csv.py
Open other terminal, and run the following command (pgrep ...
will give you the pid of the previous command)
cpulimit --limit=10 -p `pgrep -f read_heavy_csv\.py`
Please note that pgrep uses RegEx patterns, not simple strings.
Upvotes: 2
Reputation: 31
You can do the following:
cpulimit --limit 50 -- python /explicit-path-to-file/extractSift.py start
Upvotes: 3