resources
pykmhelpers.core.resources
Helpers for inspecting and adjusting process resource limits (ulimits).
get_ulimit(resource_type=resource.RLIMIT_NOFILE)
get_available_ram(safety_margin=1.0)
Return usable RAM in bytes: currently available memory scaled down by safety_margin.
Source code in pykmhelpers/core/resources.py
get_available_threads(safety_margin=1.0)
Return a safe thread count: CPUs available to this process, scaled down by safety_margin.
Source code in pykmhelpers/core/resources.py
get_max_open_files(safety_margin=1.0)
Return a safe open-files ceiling: the hard RLIMIT_NOFILE scaled down by safety_margin.
The hard limit, not the soft one: maximize_nofile raises the soft limit
to it before anything is run (CLI start, kmtricks and kmindex calls, and
the generated scripts). An unlimited hard limit counts as NOFILE_CEILING.
Source code in pykmhelpers/core/resources.py
maximize_nofile()
Raise the open-files (RLIMIT_NOFILE) limit to the highest allowed value.
Returns the soft limit in effect afterwards. A failure is logged, not raised: the process keeps its current limit.