python-3.x - Subprocess.check_output 进入挂起状态
问题描述
尽管 yaml 被执行并且执行完成了,python 代码仍然不会终止。
subprocess.check_output("nohup ansible-playbook ansible_final.yml -u ec2-user &",shell=True)
解决方案
使用下面的代码
with open('error.err','w') as ferr, open('output.out','w') as fout:
p=subprocess.Popen('ansible-playbook ansible_final.yml -u ec2-user &', stdout=fout, stderr=ferr,preexec_fn=os.setsid,shell=True)
推荐阅读
- javascript - 其他控制器未收到角度广播事件
- javascript - 除非选择特定变体,否则隐藏输入字段 - Shopify
- python - 在 Python 中的 API 网关请求中使用 AWS Cognito 访问令牌
- xslt-2.0 - 如何匹配元素中区分大小写的字符
- php - 如何在 PHP 中用已有的数字替换字符串
- cordova - Ioniv-v4:离子cordova插件添加cordova-plugin-googleplus不工作
- xcode - macOS NSExtensionMainStoryboard 无法加载
- ionic-framework - 如何在 ngSwitchCase 中加载离子图像?
- sql - 如何提高以下查询的性能
- python-3.x - couchbase 合并数组到子文档