1

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

1
  • 2
    cpulimit does not launch the process, it searches for it. So is your python program already running when you run cpulimit? If not, then it should be. Specifying the pid is probably safer. Commented Feb 24, 2016 at 7:52

2 Answers 2

3

You can do the following:

cpulimit --limit 50 -- python /explicit-path-to-file/extractSift.py start

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.