You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 11与10下Python启动分离进程的差异及问题咨询

关于Windows 11中Python启动分离Robot Framework进程的问题及疑问

原实现代码(Python 3.7-3.11)

我曾用Python编写代码启动分离的Robot Framework进程:

import subprocess
process = subprocess.Popen([robot.exe,[your_test_path]], shell=True, stdin=None, stdout=None, stderr=None, close_fds=True)

实现进程分离的关键参数为:

shell=True, stdin=None, stdout=None, stderr=None, close_fds=True

问题与修改后的可行代码

上述代码在Windows 11上失效:父进程停止后,子进程会立即终止。经调研后修改为以下代码,目前可在Windows 10和11上正常运行:

process = subprocess.Popen([robot.exe,[your_test_path]], shell=True, stdin=None, stdout=None, stderr=None, close_fds=True, start_new_session=True, creationflags=subprocess.DETACHED_PROCESS)

其中起关键作用的参数似乎是:

creationflags=subprocess.DETACHED_PROCESS

待解答的疑问

  • Windows 11究竟发生了什么变化,导致原代码失效?
  • 启动最小化/隐藏的分离进程的最佳方式是什么?
  • 为何测试notepad.exe时原方案在Windows 11上可行,但Robot Framework却不行?
  • 启动过程中出现的奇怪嵌入式终端窗口进程是什么原因?

内容的提问来源于stack exchange,提问作者Dibi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 19:36:20