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

[Bug] 通过REST API占用设备并获取远程,不能立即使用连接 #368

Open
2 tasks done
mocobk opened this issue Jul 18, 2023 · 2 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@mocobk
Copy link

mocobk commented Jul 18, 2023

Search before asking

  • I searched in the issue and found nothing similar. | 我查找了并确认issue列表无相似报告。

Sonic version

2.6.1

Deploy platform

Macosx

Minimal reproduce step

  1. 用 REST API 获取 uia2 连接地址
  2. 在脚本中立即使用 uia2 地址初始化 AndroidDriver
  3. 执行方法会出现报错情况

获取 uia2 地址需要强制等待设备 server 启动完成,建议这里做成阻塞式接口或能获取是否启动完成的状态,避免脚本强制等待一个时间

Are you willing to submit a PR?

  • I'm willing to submit a PR! | 我将发起PR!
@mocobk mocobk added the bug Something isn't working label Jul 18, 2023
@ZhouYixun
Copy link
Member

ZhouYixun commented Jul 18, 2023 via email

@mocobk
Copy link
Author

mocobk commented Feb 28, 2024

采用了client 轮询的方式临时解决了

    def wait_remote_server_ready(remote_url, timeout=30):
        """等待远程服务准备好"""
        time_start = time.time()
        while time.time() - time_start <= timeout:
            time.sleep(1)
            logger.debug('check remote server status...')
            response = request_with_proxy('GET', remote_url + '/status')
            if response.status_code != 200:
                continue
            result = response.json()
            if result.get('value', {}).get('ready'):
                logger.info(f'{result["value"].get("message")}')
                return
        raise TimeoutError('wait remote server ready timeout')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants