美文网首页
subprocess.Popen() 跑完不能正常关闭端口

subprocess.Popen() 跑完不能正常关闭端口

作者: tafanfly | 来源:发表于2018-08-28 16:21 被阅读0次

    背景,用下面的命令, 端口不能正常关闭

    1. python 中使用 subprocess.Popen()
    2. robotframework 中使用 start process, 本质上其实用到的还是 subprocess.Popen()

    解决

    1. 如果是python, 记得 subprocess.Popen() 必须加上close_fds=True
    process = subprocess.Popen(command, close_fds=True, **conf.popen_config)
    
    1. 如果是robotframework 的 start process, 需要修改/robot/libraries 下的process 文件, 给subprocess.Popen() 加上参数 close_fds=True
    python -c 'import robot; print robot.libraries.__path__[0]'
    /home/***/.local/lib/python2.7/site-packages/robot/libraries
    

    相关文章

      网友评论

          本文标题:subprocess.Popen() 跑完不能正常关闭端口

          本文链接:https://www.haomeiwen.com/subject/yjkqwftx.html