【问题标题】:Dangers of running Appium as a python subprocess?将 Appium 作为 python 子进程运行的危险?
【发布时间】:2015-07-08 03:48:50
【问题描述】:

我正在使用 Appium 进行 UI 测试,以及上面的 Robot Framework。我正在尝试自动化测试 iOS 应用程序所需的所有服务器和服务,包括 Appium 服务器。这似乎在 Appium 内部造成了一些破坏。特别是,我们在调用 driver.get_elements_by_accessibility_id(id) 时似乎卡住了

子流程启动如下所示:

self.app = subprocess.Popen("appium", shell=True, stdout=PIPE, stderr=PIPE)

当我们删除 stdout/stderr kwargs,或让它们指向文件时,行为恢复正常。是否有一些对 stdout/stderr 的依赖导致了这种情况?

【问题讨论】:

    标签: python subprocess appium


    【解决方案1】:

    不要使用PIPE,除非你从管道中读取,例如使用out, err = self.app.communicate()。否则,子进程可能会挂起,这就是subprocess.call() docs warn

    不要在此函数中使用stdout=PIPEstderr=PIPE。孩子 如果进程向管道生成足够的输出以填满,则进程将阻塞 操作系统管道缓冲区,因为管道没有被读取。

    subprocess.call() 不消耗管道,因此您不应将PIPE 传递给它。 To discard output, you could use DEVNULL instead。如果您以后不使用self.app.stdout/stderr,这同样适用于Popen()

    【讨论】:

    • 谢谢,我应该再看一遍文档。时间太长了。
    猜你喜欢
    • 2010-12-10
    • 2011-12-28
    • 2019-10-17
    • 2013-04-28
    • 2012-02-23
    • 2010-12-28
    • 2015-08-05
    • 1970-01-01
    • 2011-07-27
    相关资源
    最近更新 更多