subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
# grep -v grep 排除自身,wc -l 统计行数 # 注意:这只是一个简易的软限制,不够精确但能防止瞬间炸机 cmd = "ps -ef | grep worker.py | grep -v grep | wc -l" result = subprocess.check_output(cmd, shell=True) count = int(result.strip()) MAX_CONCURRENT_WORKERS = 5- Confidence
- 91% confidence
- Finding
- result = subprocess.check_output(cmd, shell=True)
