Reputation: 3437
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)
Upvotes: 7
Views: 11807
Reputation: 76
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.
Upvotes: 6