sinat_25869705 2023-03-16 17:02 采纳率: 0%
浏览 19

python执行exe提示Process finished with exit code -1073741819 (0xC0000005)

现象:PYQT5+PY3.6开发,生成执行exe闪退,无异常就提示Process finished with exit code -1073741819 (0xC0000005)

代码:

    # TCPclient按钮
    def clientmain(self):
        try:
            # 主机地址
            if self.comboBoxchose_TCP.currentText()=="TCPClient":
                global toSend,IP,SERVER_PORT,dataSocket,BUFLEN,toSendSet
                IP = str(self.lineEditsd_TCPIP.text())
                SERVER_PORT = int(self.lineEditsd_TCPDK.text())
                BUFLEN =1024
                # 实例化对象
                dataSocket = socket(AF_INET, SOCK_STREAM)
                dataSocket.connect((IP, SERVER_PORT))
                global t1
                if t1 in threads:
                        stop_thread(t1)
                        threads.remove(t1)
                if self.pushButtonclr_TCP.text() == "连接":
                    self.pushButtonclr_TCP.setText("断开")
                    toSend= toSendSet

                    t1 = threading.Thread(target=self.dataSocket_recv, args=(toSend,))
                    t1.start()
                    threads.append(t1)
                else:
                    toSend=""
                    dataSocket.close()
                    self.pushButtonclr_TCP.setText("连接")
        except Exception as e:
            print(e)
            open("./数据/err.txt", 'w+', encoding='utf-8').write(traceback.format_exc())

    # TCP数据处理
    def dataSocket_recv(self,toSend):
        try:
            global  IP, SERVER_PORT, dataSocket,BUFLEN,rizhi,RIZHIWJM
            global num
            global t1
            num=0
            while True:
                if toSend!="":
                    dataSocket.send(toSend.encode('utf8'))
                    #time.sleep(10)
                    out_s=toSend
                    out_s += '\r\n'
                    global rizhi, RIZHIWJM
                    if rizhi == "True":
                        with open(RIZHIWJM, "a+", encoding="utf-8", errors='ignore') as f:
                            f.writelines(out_s)
                            f.flush()
                    # print("循环发送数据out_s")
                    # self.plainTextEdit.insertPlainText(out_s)
                    self.plainTextEdit.appendPlainText(out_s)
                    # 获取到text光标
                    # print("获取到text光标")
                    textCursor = self.plainTextEdit.textCursor()
                    # 滚动到底部
                    # print("滚动到底部")
                    textCursor.movePosition(textCursor.End)
                    # 设置光标到text中去
                    # print("设置光标到text中去")
                    self.plainTextEdit.setTextCursor(textCursor)
                    # print("设置plainTextEdit")

                    toSend = ""
                recved = dataSocket.recv(BUFLEN)
                if not recved:
                    pass
                if self.pushButtonclr_TCP.text() == "连接":
                    dataSocket.close()
                    break
                time.sleep(0.7)
                #print(recved.decode('gbk', errors='ignore'))
                if rizhi == "True":
                    with open( RIZHIWJM, "a+", encoding="gbk", errors='ignore') as f:
                        f.writelines(recved.decode('gbk', errors='ignore'))
                        f.flush()
                self.plainTextEdit.appendPlainText(recved.decode('gbk', errors='ignore'))
                num = len(recved)
                self.data_num_received += num
                if self.data_num_received > 1048576:
                    self.plainTextEdit.clear()
                    self.data_num_received = 0
                    self.data_num_sended = 0
                # time.sleep(0.5)
                # 获取到text光标
                textCursor = self.plainTextEdit.textCursor()
                # 滚动到底部
                textCursor.movePosition(textCursor.End)
                # 设置光标到text中去
                self.plainTextEdit.setTextCursor(textCursor)

            #dataSocket.close()
            if t1 in threads:
                stop_thread(t1)
                threads.remove(t1)
        except Exception as e:
            print(e)
            open("./数据/err.txt", 'w+', encoding='utf-8').write(traceback.format_exc())

求各位同行指教,EXE闪退时间不一定,不好分析也没有抓取到异常。

  • 写回答

3条回答 默认 最新

  • threenewbee 2023-03-16 17:09
    关注

    检查下进程为什么退出,进程退出的原因是什么

    评论

报告相同问题?

问题事件

  • 创建了问题 3月16日

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用