我想用限时的adb wait-for-device
,但是好像没有超时功能,
我的解决方法如下,有没有更有效的方法来实现它?
#<python on Windows>
t0 = datetime.datetime.now()
cmd = 'date'
cmd = 'adb -s %s shell \"'+ cmd+ '\"'
r = 1
while(r!=0 and (t1-t0).seconds < 60):
r = os.system(cmd)
t1 = datetime.datetime.now()
2条答案
按热度按时间toiithl61#
没有特定的Timeout方法可用,但您可以尝试
a7qyws3x2#
PowerShell
Wait-*
cmdlet具有可以使用的超时选项。您可以使用Wait-Job
来完成此操作您可以将其放入配置文件中以供重用。在PowerShell中运行
notepad $PROFILE
并粘贴以下函数例如,以40 s超时运行
另一个内置解决方案是ScriptRunner.exe,但它会在新窗口中打开进程
行为与使用
Start-Process
和Wait-Process
而不是Start-Job
/Wait-Job
运行上述PowerShell代码段时相同