Poco icon indicating copy to clipboard operation
Poco copied to clipboard

脚本长时间运行后,poco调用java代码出错,报错:hrpc.exceptions.RpcRemoteException: java.lang.IndexOutOfBoundsException

Open ruoyufufeng opened this issue 4 years ago • 5 comments

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

(重要!问题分类)

  • 控件识别、树状结构、poco库报错

描述问题bug

编写的脚本任务是爬取评论,当脚本长时间执行的时候,airtest会报RpcRemoteException,短时间执行不会出错。

======================================================================
ERROR: runTest (app.widgets.code_runner.ide_launcher.AirtestIDECase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "airtest\cli\runner.py", line 65, in runTest
  File "site-packages\six.py", line 693, in reraise
  File "airtest\cli\runner.py", line 61, in runTest
  File "D:\airtest\airtestProject\vivoComment.air\vivoComment.py", line 40, in <module>
    if (mynode.offspring("com.bbk.appstore:id/comment_user").exists() and
  File "D:\airtest\AirtestIDE_2020-01-21_py3_win64\AirtestIDE_2020-01-21_py3_win64\poco\proxy.py", line 72, in wrapped
    return func(proxy, *args, **kwargs)
  File "D:\airtest\AirtestIDE_2020-01-21_py3_win64\AirtestIDE_2020-01-21_py3_win64\poco\proxy.py", line 774, in exists
    return self.attr('visible')
  File "D:\airtest\AirtestIDE_2020-01-21_py3_win64\AirtestIDE_2020-01-21_py3_win64\poco\proxy.py", line 39, in wrapped
    return func(self, *args, **kwargs)
  File "D:\airtest\AirtestIDE_2020-01-21_py3_win64\AirtestIDE_2020-01-21_py3_win64\poco\proxy.py", line 734, in attr
    nodes = self._do_query(multiple=False)
  File "D:\airtest\AirtestIDE_2020-01-21_py3_win64\AirtestIDE_2020-01-21_py3_win64\poco\proxy.py", line 872, in _do_query
    self._nodes = self.poco.agent.hierarchy.select(self.query, multiple)
  File "D:\airtest\AirtestIDE_2020-01-21_py3_win64\AirtestIDE_2020-01-21_py3_win64\poco\utils\retry.py", line 15, in wrapped
    return func(*args, **kwargs)
  File "D:\airtest\AirtestIDE_2020-01-21_py3_win64\AirtestIDE_2020-01-21_py3_win64\poco\utils\hrpc\hierarchy.py", line 33, in select
    return self.selector.select(query, multiple)
  File "hrpc\object_proxy.py", line 92, in __call__
  File "hrpc\client.py", line 81, in evaluate
hrpc.exceptions.RpcRemoteException: java.lang.IndexOutOfBoundsException: 

|--   Remote Traceback   --|

java.lang.IndexOutOfBoundsException
	at java.util.LinkedList.get(LinkedList.java:519)
	at com.netease.open.libpoco.sdk.Selector.selectImpl(Selector.java:93)
	at com.netease.open.libpoco.sdk.Selector.selectImpl(Selector.java:66)
	at com.netease.open.libpoco.sdk.Selector.select(Selector.java:37)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.netease.open.hrpc.backend.RpcServer.onRequest(RpcServer.java:171)
	at com.netease.open.hrpc.backend.RpcServer.serve(RpcServer.java:57)
	at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:840)
	at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:189)
	at java.lang.Thread.run(Thread.java:818)


|--   Remote Traceback end   --|

----------------------------------------------------------------------
Ran 1 test in 861.010s

FAILED (errors=1)
[02:05:03][DEBUG]<airtest.core.android.adb> D:\airtest\AirtestIDE_2020-01-21_py3_win64\AirtestIDE_2020-01-21_py3_win64\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s f709dc0c7d23 forward --remove tcp:16150
[02:05:03][DEBUG]<airtest.core.android.adb> D:\airtest\AirtestIDE_2020-01-21_py3_win64\AirtestIDE_2020-01-21_py3_win64\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s f709dc0c7d23 forward --remove tcp:17360
[02:05:03][DEBUG]<airtest.core.android.adb> D:\airtest\AirtestIDE_2020-01-21_py3_win64\AirtestIDE_2020-01-21_py3_win64\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s f709dc0c7d23 forward --remove tcp:13708
[Finished]

============================================================

复现步骤

  1. 点击运行脚本 2.长时间运行后就会出错,大约15分钟开始报错并停止执行脚本,此时大约爬取到200条评论信息。

预期效果 一直执行到爬取到所有的评论为止,大约7万余条

相关截图 (贴出遇到问题时的截图内容,如果有的话) 批注 2020-06-30 150900

python 版本: python3.6

poco 版本: 1.0.79

设备: 小米

  • 型号: [redmi 3s]
  • 系统: [Android 6.0.1]

其他相关环境信息 (windows上运行,无论是airtest ide还是pychram,长时间运行脚本,都会报同样的错误)

ruoyufufeng avatar Jun 30 '20 07:06 ruoyufufeng

+1

alook123 avatar Aug 24 '20 09:08 alook123

+1

chengc avatar Feb 02 '21 09:02 chengc

+1

cnscorpions avatar May 01 '21 13:05 cnscorpions

+1,代码运行过长就会出现,然后再继续爬就不会出错: 报错指向的代码: image

报错信息: 9FF69176A60BD95A241D9FC5DAC59DD9

InsaneLife avatar Feb 24 '22 12:02 InsaneLife

解决了,方法:在有点击等操作之后,增加等待时间,如:sleep(15) 在每次点击操作之后,不能马上就爬取,因为页面还没有完全加载,这时候爬取,就会出现数组越界,亲测有效,不是airtest问题。

InsaneLife avatar Feb 24 '22 16:02 InsaneLife