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

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

root6年前 (2021-01-19)linux1953

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

分享给朋友:

相关文章

linux 更换apt的源

sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list将archive.ubunt...

linux 切割文件split

split --help 用法:split [选项]... [输入 [前缀]] 将输入内容拆分为固定大小的分片并输出到"前缀aa"、"前缀ab",...;...

修改linux时区

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

zabbix 中文乱码

zabbix 中文乱码

原因是因为zabbix没有支持中文的字体,在win找到一个中文字体文件名是:simkai.ttf把这个文件复制到服务器的/usr/share/zabbix/fonts  路径下然后修改zabbix的配置文件vim /us...

centos切勿执行yum -y update

yum update 跟apt-get update 不一样centos的yum update相当于ubuntu的apt upgrade如果想用ubuntu的apt update,centos是yum makecache因为执行yum -y...

linux创建用户和用户组

添加用户和组groupadd testuseradd -r -g test test删除用户和组userdel testgroupdel test给文件添加用户组和用户归属chown -R test:test test_file...