Python PyQT在睡眠后崩溃
我使用python3.5.2和PyQt4 我正在使用PyQt连接并使用.ocxPython PyQT在睡眠后崩溃,python,pyqt,pyqt4,python-3.5,Python,Pyqt,Pyqt4,Python 3.5,我使用python3.5.2和PyQt4 我正在使用PyQt连接并使用.ocx from PyQt4.QAxContainer import QAxWidget if __name__ == "__main__": app = QApplication(sys.argv) while True: # run some codes that use QAxWidget.dynamicCall() function
from PyQt4.QAxContainer import QAxWidget
if __name__ == "__main__":
app = QApplication(sys.argv)
while True:
# run some codes that use QAxWidget.dynamicCall() function
# print some results
sleep(30)
在休眠并返回主代码后,我得到了“进程结束,退出代码为-1073740771(0xC000041D)”
我试着用try。。。除了子句,但无法捕获错误
我应该思考什么问题
如何调试
编辑:
事故报告:
程序名:python.exe,版本:3.5.1150.1013,时间戳:0x576eff6a
模块名称:QAxContainer.pyd,版本:0.0.0.0,时间戳:0x56123368
异常代码:0xc000041d
错误偏移量:0x0001301
进程ID:0x4d24
EDIT2:
如果我将sleep(30)设置为sleep(10),它将正常工作,不会发生任何崩溃。我可以成为处理应用程序的垃圾收集器。
因此,尝试将应用程序放在全球范围内 试着这样做:
from PyQt4.QAxContainer import QAxWidget
app = None
if __name__ == "__main__":
app = QApplication(sys.argv)
while True:
# run some codes that use QAxWidget.dynamicCall() function
# print some results
sleep(30)
我想问题是,如果您使用
time.sleep(30)
,您的程序会在半分钟内保持无响应,以至于Windows怀疑它已崩溃并终止进程。为什么需要睡觉?一个好的经验法则是:不要在pyqt应用程序中使用time.sleep()
。