简体   繁体   English

可以使用python脚本(或任何其他编程语言脚本)来限制其他应用程序使用的资源(如RAM,CPU使用情况)吗?

[英]Can python script (Or any other programming language scripts) be used to restrict resources (like RAM, CPU Usage) used by other applications?

For my project, I am supposed to measure system performance of OpenStack SWIFT based on available resources like RAM, CPU, etc.. So, I was wondering, can I use a python script or some other programming language scripts to restrict the resources usage by OpenStack SWIFT to measure the impacts of those resources on the OpenStack SWIFT ??? 对于我的项目,我应该根据RAM,CPU等可用资源来测量OpenStack SWIFT的系统性能。所以,我想知道,我可以使用python脚本或其他一些编程语言脚本来限制资源的使用OpenStack SWIFT测量这些资源对OpenStack SWIFT的影响???

Please reply!!! 请回复!!!

By using python resource module you can set the resource limit, please check more detail in the official docs resource 通过使用python资源模块,您可以设置资源限制,请在官方文档资源中查看更多详细信息

import resource
resource.setrlimit(resource.RLIMIT_CPU, (1, 1))

By using subprocess you can change the ulimit : system wide resource and nice level ie scheduling priority. 通过使用子进程,您可以更改ulimit :系统范围的资源和良好的级别,即调度优先级。

import subprocess
subprocess.Popen('ulimit -t 10; nice -n 15 application_name', shell=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过 python 或任何其他编程语言控制网页 - Control a webpage trough python or any other programming language 在 MS Excel 中导入 xml 文件 - 我们如何使用 Python 或任何其他编程语言自动化此流程? - Importing xml file in MS Excel - How can we automate this flow using Python or any other programming language? 使用 python 脚本上使用的 % 资源记录 - Log with % resources used on python script Python CPU 和 RAM 内存使用情况 - Python CPU and RAM memory usage 还有什么其他特殊字符如“\\ r”可以用来美化Python中的输出? - What other special characters like “\r” can be used to prettify output in Python? 脚本导致另一台电脑上的其他脚本(python) - Scripts result to a other script on a other pc (python) Python可以用作Windows Server环境的有效脚本语言吗? - Can Python be used as an effective script language for Windows Server environment? 其他编程语言中的Python循环传输 - Python loop transfer in other programming language 用于生成Bash脚本的Python脚本中的KeyError - KeyError in Python script used to generate Bash scripts 如何将Tcpreplay添加为C语言或任何其他编程语言的库? - How to add Tcpreplay as a library in C language or any other programming language?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM