7

Is it possible for a Python script to limit the CPU power allocated to it?

Right now, I have a script (using only one core) that is using 100% of one CPU's core. I need it to use less than that amount.

Is there an equivalent to PHP's memory_limit in Python? or is there a library to manage memory allocation? (using sleep isn't a very elegant solution)

1 Answer 1

6

Maybe try Python's resource package?

The resource package is basically a wraparound of setrlimit in UNIX. So you can set constrains for CPU/Memory usage, etc.

More about setrlimit in Linux

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

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.