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

2018-08-28  本文已影响0人  tafanfly

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

  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
上一篇下一篇

猜你喜欢

热点阅读