python - 如何停止接收 QThread?
问题描述
我有一个 QThread 对象,我想从主程序中停止它,但它卡在了 recv 方法中。有没有办法在调用 close_worker 函数时停止 recv 方法?
# Main function of the thread
def handle:
while self.run:
data = sock.recv(data_size)
self.intReady.emit(msg)
# Stop the thread
def close_worker(self):
self._mutex.lock()
self.run = False
self._mutex.unlock()
解决方案
推荐阅读
- genetics - 如何使用 Plink2 在命令行中运行 GWAS?
- javascript - 在 Heroku 中使用 React 应用程序没有错误,但为什么只有在上传图片时才会出现错误?
- r - 将字符转换为日期 (R)
- makefile - 使用 makefile 编译时对“zmq_ctx_new”的未定义引用
- android - 致命异常:尝试添加 cardCornerRadius 时错误膨胀类片段
- powershell - Powershell 中的 AD 查询将结果合并到 .CSV 文件中
- reactjs - SSG 和 next.js 无法实时判断屏幕大小
- sql-server - 下表中提供的表中“键”中的“0/1”是什么意思,软件使用 Microsoft SQL Server Managament Studio 2018
- javascript - Java解压LZMA-JS压缩文件
- django - 无法在 Apache mod_wsgi django 服务器上设置 https 并启用 ssl