运行 Appium 作为 python 子进程的危险?
Dangers of running Appium as a python subprocess?
我正在使用 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,或使它们指向文件时,行为 returns 正常。是否对 stdout/stderr 有某种依赖性导致了这种情况?
不要使用 PIPE
,除非您从管道读取数据,例如使用 out, err = self.app.communicate()
。否则,子进程可能会挂起,这就是为什么 subprocess.call()
docs warn:
Do not use stdout=PIPE
or stderr=PIPE
with this function. The child
process will block if it generates enough output to a pipe to fill up
the OS pipe buffer as the pipes are not being read from.
subprocess.call()
不会消耗管道,因此您不应将 PIPE
传递给它。 To discard output, you could use DEVNULL
instead。如果您以后不使用 self.app.stdout/stderr
,则同样适用于 Popen()
。
我正在使用 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,或使它们指向文件时,行为 returns 正常。是否对 stdout/stderr 有某种依赖性导致了这种情况?
不要使用 PIPE
,除非您从管道读取数据,例如使用 out, err = self.app.communicate()
。否则,子进程可能会挂起,这就是为什么 subprocess.call()
docs warn:
Do not use
stdout=PIPE
orstderr=PIPE
with this function. The child process will block if it generates enough output to a pipe to fill up the OS pipe buffer as the pipes are not being read from.
subprocess.call()
不会消耗管道,因此您不应将 PIPE
传递给它。 To discard output, you could use DEVNULL
instead。如果您以后不使用 self.app.stdout/stderr
,则同样适用于 Popen()
。