python - 使用 PyQt5 和 GNURadio 避免退出代码 -1073741819 (0xC0000005)
问题描述
我在 Windows 10 上,我必须编写一个 Python 脚本,该脚本调用一个带有 PYQT5 GUI 图的 GNURadio 应用程序。从使用 GNURadio Companion 制作的顶级块类开始,我需要添加一些功能:
- 应该安排 GNURadio 应用程序的启动(我正在使用 aps 后台调度程序,因为我需要释放主线程,在该主线程中我需要在套接字上做一些事情)
- 该应用程序应在一定秒数后自动终止(我尝试使用 threading.Timer 模块)。
这是一个由 GNURadio 自动生成的 main 函数的示例。
def main(top_block_cls=test01, options=None):
if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def sig_handler(sig=None, frame=None):
tb.stop()
tb.wait()
Qt.QApplication.quit()
signal.signal(signal.SIGINT, sig_handler)
signal.signal(signal.SIGTERM, sig_handler)
timer = Qt.QTimer()
timer.start(500)
timer.timeout.connect(lambda: None)
qapp.exec_()
由于aps后台调度程序在与主线程不同的线程(即ThreadPoolExecutor-0_0)上启动脚本,因此信号模块引发错误,因此我认为它不能用于我的目的。我尝试使用下一个代码,其中我删除了信号线并添加了调用相同 sig_handler 的计时器。该应用程序关闭,但我得到一个退出代码 -1073741819 (0xC0000005),它关闭了整个程序,甚至是主线程,而我必须保持它运行。
def main(seconds: float, top_block_cls=test01, options=None):
if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def sig_handler(sig=None, frame=None):
tb.stop()
tb.wait()
Qt.QApplication.quit()
Timer(seconds, sig_handler).start()
timer = Qt.QTimer()
timer.start(500)
timer.timeout.connect(lambda: None)
qapp.exec_()
有谁知道如何解决它?
解决方案
推荐阅读
- wordpress - 仅使用 WordPress 作为发布数据库来提供您自己的自定义站点
- java - 嗨我正在尝试从离子角度应用程序构建方舟,在构建过程中出现错误
- javascript - JSDoc 重载函数不适用于 TypeScript
- c++ - (CMake 构建)致命错误 LNK1181:无法打开输入文件 'glew.lib'
- sql - 本机查询在 h2 上返回结果,但不在 jpa 存储库中
- sql-server - Visual Studio 数据库项目在本地计算机上构建,但在构建服务器上失败
- python - 从 git 安装 python API
- javascript - 允许最终值通过后,有没有办法完成流?
- ios - 通过本机 facebook 应用程序的授权错误
- go - golang中的依赖注入