AdbClient错误:[Errno 10053]已建立的连接已中止

2024-04-28 14:44:28 发布

您现在位置:Python中文网/ 问答频道 /正文

当我发出一个device.takeSnapshot()命令和设备.触摸()命令:

    Traceback (most recent call last):
  File "C:\Users\Me\Desktop\AndroidViewClient_Bots\pytesser\insta_get_list_of
_users.py", line 82, in <module>
    device.touch(213,481, 'DOWN_AND_UP')
  File "C:\Python27\lib\site-packages\androidviewclient-7.0.2-py2.7.egg\com\dtmi
lano\android\adb\adbclient.py", line 425, in touch
    self.shell('input tap %d %d' % (x, y))
  File "C:\Python27\lib\site-packages\androidviewclient-7.0.2-py2.7.egg\com\dtmi
lano\android\adb\adbclient.py", line 257, in shell
    self.__send('shell:%s' % cmd, checkok=True, reconnect=False)
  File "C:\Python27\lib\site-packages\androidviewclient-7.0.2-py2.7.egg\com\dtmi
lano\android\adb\adbclient.py", line 154, in __send
    self.__checkOk()
  File "C:\Python27\lib\site-packages\androidviewclient-7.0.2-py2.7.egg\com\dtmi
lano\android\adb\adbclient.py", line 184, in __checkOk
    recv = self.socket.recv(4)
socket.error: [Errno 10053] An established connection was aborted by the softwar
e in your host machine

这是我的代码:

^{pr2}$

真的很奇怪因为如果我

my_img = device.takeSnapshot() 

或者

device.touch(200,300, 'DOWN_AND_UP')

那我就不会出错了。但是,在同一个代码中,它一起生成上述错误。在发出多个设备命令时,是否有什么我没有做的事情?在


Tags: inpycomeggdevicelibpackagesline
1条回答
网友
1楼 · 发布于 2024-04-28 14:44:28

我想这有点棘手。 您的问题可能来自于device.takeSnapshot()被定义为

def takeSnapshot(self, reconnect=False):
    '''
    Takes a snapshot of the device and return it as a PIL Image.
    '''

    ...

因此,如果您计划在拍摄快照后继续使用连接,请使用

^{pr2}$

相关问题 更多 >