当 运行 通过 Python 子进程时,使用仪器获取 iDevices 卡住了

Getting iDevices using instruments got stuck when running through Python subprocess

我正在编写一个简单的 python 脚本,使用 Subprocess 来获取附加到我的 mac 的 iDevices 列表。我使用的命令是 "instruments -s devices"。当我通过命令行 运行 时,此命令工作正常,但当我使用子进程使用相同命令时遇到问题。

下面是我的简单python脚本

    import subprocess

    cmd = ['instruments', '-s', 'devices']
    response = subprocess.Popen(cmd,stdout=subprocess.PIPE)
    print response.communicate()

当我运行上面的python命令

时,我的终端屏幕如下所示
MacBook-Pro-9:lib darren$ python iOSRemoteLib.py
2016-09-05 14:30:38.648 instruments[21276:1052546] WebKit Threading Violation - initial use of WebKit from a secondary thread.

python 进程挂起并且没有返回任何响应。看起来像是一些线程问题,我无法弄清楚是什么。

谢谢

你们有两个版本的Xcode吗? 我面临着 subprocess(instruments -s devices) 挂起的完全相同的问题。我有 XCode 8.0 和 7.3.1。只有在我切换到 7.3.1 后才会出现此问题。事实证明 subprocess.Popen('sudo instruments -s devices', stdout=subprocess.PIPE) 工作得很好。所以可能是权限问题。