当前位置:首页 > linux > 正文内容

Python2 的Popen在docker中执行会挂起主进程

root6年前 (2021-01-19)linux1901

python2.7

因业务需求。要把程序放入到docker容器中

但是在docker执行的时候程序出现异常缓慢的情况

检查函数执行情况发现

当第一个线程执行到popen的时候会导致所有线程的挂起

p1 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)


原因是py2的bug

类似问题

解决方案 pip install subprocess32 

替代subprocess

p1 = subprocess.Popen32(command, shell=True, stdout=subprocess32.PIPE, stderr=subprocess32.STDOUT, close_fds=True)


https://bugs.python.org/issue42950

能使用py3还是使用py3吧

扫描二维码推送至手机访问。

版权声明:本文由一叶知秋发布,如需转载请注明出处。

本文链接:https://www.zhiqiu.top/?id=73

分享给朋友:

相关文章

压缩&解压命令

tar 命令-c 建立压缩文档-x 解压-t 查看内容-r 向压缩归档文件末尾追加文件-u:更新原压缩包中的文件上面的参数只能使用一个,跟下面的参数连用-z:有gzip属性的-j:有bz2属性的-Z:有compress属性的-v:...

修改linux时区

ubuntu:rm  /etc/localtimeln -sf /usr/share/zoneinfo/Asia/Shanghai  /etc/localtimecentos echo "A...

python安装的时候出现python setup.py egg_info Check the logs for full command output

python安装的时候出现python setup.py egg_info Check the logs for full command output

解决yum install python2-develpip install --upgrade setuptools...

docker 日志查看

通过如下命令来获取容器的日志地址 docker inspect --format '{{.LogPath}}' 97069f94437bcat命令查看上述命令找到的日志地址cat /...

办公室千兆服务器之间scp的传输速度被限制在3MB/s

服务器之间拷贝文件是十分常见的操作但是有时候会遇见一个问题,拷贝的速度是相当的缓慢。遇见问题就开始分析问题影响网络网络传输有:服务器a和b、服务器网卡A和B、网线、交换机、路由器由于服务器a和b在同一台交换机不考虑路由器的因素查看服务器网卡...

git 忽略文件不起作用 .gitignore

git rm -r --cached . git add .   git commit -m "update .gitignore"  git status查看是否是"working di...