Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

airtest断开连接:orientationWatcher has ended #191

Closed
silencesmile opened this issue Oct 23, 2018 · 12 comments
Closed

airtest断开连接:orientationWatcher has ended #191

silencesmile opened this issue Oct 23, 2018 · 12 comments

Comments

@silencesmile
Copy link

(请尽量按照下面提示内容填写,有助于我们快速定位和解决问题,感谢配合。否则直接关闭。)

(重要!问题分类)
Python代码控制airtest时,中间使用adb命令可能导致airtest断开连接,当我使用多线程操作其他adb命令时,为什么同样也会断开连接,当断开连接后我重新创建爱airtest为什么还是不能继续使用

描述问题bug
Python代码控制airtest时,中间使用adb命令可能导致airtest断开连接,当我使用多线程操作其他adb命令时,为什么同样也会断开连接,当断开连接后我重新创建爱airtest为什么还是不能继续使用

[01:35:48][INFO]<airtest.core.api> Try finding:
zzz ./newGameICO1.1/home/home_level.png
Template(./newGameICO1.1/home/home_mouse.png)
[01:35:48][DEBUG]<airtest.core.android.rotation> orientationWatcher has ended
点击图片失败: ./newGameICO1.1/home/home_mouse.png
zzz ./newGameICO1.1/home/home_mouse.png

相关截图
image

复现步骤

#点击某个图片,Airtest中基于图像识别语法,图片自己提供。

for img in imgs:
airtest.touch_img(img)
print('zzz', img)

# # 开启多线程进行截图
screen_path = './phoneIMG/' + img[20: -3] + 'PNG'
thread = threading.Thread(target=getScreen, args=(screen_path,))
thread.start()

预期效果
多线程(代码时通过adb截取手机屏幕)不影响airtest的继续运行

python 版本: python3.5
python3.6.5

airtest 版本: 1.0.69
airtest:1.0.23

设备:

  • 型号: 红米note3
  • 系统: Android5.1.1
@yimelia
Copy link
Member

yimelia commented Oct 23, 2018

不要在运行airtest脚本的同时运行ADB指令……会相互抢占导致ADB不断重启的

@silencesmile
Copy link
Author

我再重新创建airtest,再抢占回来也不行吗

@yimelia
Copy link
Member

yimelia commented Oct 23, 2018

目前暂时最好不要这么做,或者等待下一次airtest的版本更新ADB之后,统一你的本地adb环境之后可能可以解决

@silencesmile
Copy link
Author

我需要在运行airtest步骤的中间去执行其他的adb命令,然后在回来接着执行airtest,现在有办法解决吗 ?

@yimelia
Copy link
Member

yimelia commented Oct 23, 2018

可以用airtest里封装的adb来尝试执行,参考文档

@wcp1234
Copy link

wcp1234 commented Oct 24, 2018

@silencesmile 我也遇到相同的问题了,也是执行airtest过程中另外调用adb来截图出现的,请问你用airtest里封装的adb来解决这个问题了吗?

@silencesmile
Copy link
Author

silencesmile commented Oct 24, 2018 via email

@yimelia
Copy link
Member

yimelia commented Oct 24, 2018

我给个代码范例吧,类似这样

def init_adb(serialno=None, adbhost=None):
    from airtest.core.android.adb import ADB
    if not serialno:
        serialno = ADB().devices(state="device")[0][0]
    adb = ADB(serialno, server_addr=adbhost)
    adb.wait_for_device()
    return adb

class Test(object):
    def __init__(self, adb):
        self.adb = adb
    
    def get_data(self):
        # 可以自行封装多线程来获取数据,这里只是个例子
        data = self.adb.shell("ls")
        return data

@yimelia
Copy link
Member

yimelia commented Oct 24, 2018

像示例里那样,在收集数据时使用airtest中的adb,或者等下个版本更新后,将本地adb和airtest中使用的adb统一成同一个版本(目录位置airtest\airtest\core\android\static\adb\windows)即可。

@yimelia yimelia closed this as completed Oct 24, 2018
@wcp1234
Copy link

wcp1234 commented Dec 3, 2018

@yimelia
你好,我平时都是用命令行在跑用例,我看AirtestIDE 1.1.0版本上的adb版本已经更新到40,请问使用pip安装的airtest、pocoui库里的adb有同步更新吗?同步更新下本地的adb版本是否可以解决用例过程中另起线程执行adb命令的资源抢占问题了呢?

@yimelia
Copy link
Member

yimelia commented Dec 3, 2018

@wcp1234 有同步更新,执行pip install -U airtest 即可更新到最新,同时需要注意替换掉本地所有的adb.exe,统一成同一个版本(哪怕不是最新的40也可以,只要是同一个版本)

@wcp1234
Copy link

wcp1234 commented Dec 3, 2018

明白了,谢谢 @yimelia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants