Python - CPU usage limit for script

Is it possible for a python script to limit the allocation of cpu power .
Right now I have a script (using only one core ) that uses 100% one processor core. I need him to use less than this amount.

I don't know if in python there is php equivalent of memory_limit ? or if there is a library for managing memory allocation (using sleep not a very elegant solution?

Thanks.

+5
source share
1 answer

Perhaps try the Python " resource " package?

The resource bundle is basically a "setrlimit" on UNIX. This way you can set limits on CPU / memory usage, etc.

More on "setrlimit" on UNIX

Thanks @Stephane for this, this is actually my first answer.

+4
source

Source: https://habr.com/ru/post/1210971/


All Articles