STINNER Victor added the comment: For an older project (Fusil the fuzzer), I wrote a short function to sleep until the system load is lower than a threshold. I had to write such function to reduce the noise when the system is heavily loaded. I wrote that to be able to run a very long task (it takes at least 1 hour, but may run for multiple days!) on my desktop and continue to use my desktop for various other tasks.
On Linux, we can use the "cpu xxx xxx xxx ..." line of /proc/stat to get the system load. My code to read the system load: https://bitbucket.org/haypo/fusil/src/32ddc281219cd90c1ad12a3ee4ce212bea1c3e0f/fusil/linux/cpu_load.py?at=default&fileviewer=file-view-default#cpu_load.py-51 My code to wait until the system load is lower than a threshold: https://bitbucket.org/haypo/fusil/src/32ddc281219cd90c1ad12a3ee4ce212bea1c3e0f/fusil/system_calm.py?at=default&fileviewer=file-view-default#system_calm.py-5 -- I also write a script to do the opposite :-) A script to stress the system to have a system load higher or equal than a minimum load: https://bitbucket.org/haypo/misc/src/3fd3993413b128b37e945690865ea2c5ef48c446/bin/system_load.py?at=default&fileviewer=file-view-default This script helped to me reproduce sporadic failures like timeouts which only occur when the system is highly loaded. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26275> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com