简体   繁体   English

将Appium作为python子进程运行的危险?

[英]Dangers of running Appium as a python subprocess?

I'm using Appium for UI testing, and Robot Framework above that. 我正在使用Appium进行UI测试,并在其上使用Robot Framework。 I'm trying to automate all of the servers and services necessary to test an iOS app, including the Appium server. 我正在尝试自动化测试iOS应用程序(包括Appium服务器)所需的所有服务器和服务。 This seems to be causing some breakage inside Appium. 这似乎在Appium内部造成了一些损坏。 In particular, we seem so get stuck when calling driver.get_elements_by_accessibility_id(id) 特别是,在调用driver.get_elements_by_accessibility_id(id)时,我们似乎陷入了困境。

The subprocess kick-off looks like this: 子流程启动看起来像这样:

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

When we drop the stdout/stderr kwargs, or make them point at files, the behavior returns to normal. 当我们丢弃stdout / stderr kwarg或使其指向文件时,该行为将恢复正常。 Is there some dependence on stdout/stderr that causes this? 是否存在对stdout / stderr的某种依赖而导致这种情况?

Don't use PIPE unless you read from the pipes eg, using out, err = self.app.communicate() . 除非您从管道中读取,否则请不要使用PIPE ,例如,使用out, err = self.app.communicate() Otherwise, the child process may hang that is why subprocess.call() docs warn : 否则,子进程可能会挂起,这就是subprocess.call() docs warn发出警告的原因

Do not use stdout=PIPE or stderr=PIPE with this function. 请勿将此功能与stdout=PIPEstderr=PIPE一起使用。 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. 如果子进程向管道生成足够的输出以填充OS管道缓冲区,则该子进程将阻塞,因为未从中读取管道。

subprocess.call() does not consume the pipes and therefore you should not pass PIPE to it. subprocess.call()不会消耗管道,因此您不应将PIPE传递给它。 To discard output, you could use DEVNULL instead . 要放弃输出,可以改用DEVNULL The same applies to Popen() if you don't use self.app.stdout/stderr later. 如果以后不使用self.app.stdout/stderr Popen()也一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM