长时间运行后Python脚本崩溃



我有一个python 2.7脚本在Raspberry pi 3上运行。

class UIThread(threading.Thread):
   def __init__(self, threadID, name, counter, U):
    threading.Thread.__init__(self)
    self.threadID = threadID
    self.name = name
    self.counter = counter
    self.U = U
  def run(self):
    self.U.run()
def main():
  time.sleep(3)
  try:
     try:
         ###launch a UI running as background thread#####
         U = UIlib.UI()
         thread1 = UIThread(1, "UI", 1, U)
         thread1.daemon = True
         thread1.start()
     except:
         ###if there is no monitor, lanch a fake UI class#######
         U = UIlib.nomonitorUI()
         thread1 = UIThread(1, "NMUI", 1, U)
         thread1.daemon = True
         thread1.start()
         print "No Monitor detected"
         pass
    ####perform interaction with the BQ chip, contain a while true loop######
     char_balan(U)
  except:
    e = sys.exc_info()
    print e
    print "UI exit"

基于所做的是通过UART将消息发送到芯片,获取响应消息,更新日志文件并将其打印到UI上(在Python Curses创建的监视器上显示的UI)。它每1秒钟一次。

脚本没有错误运行32小时,然后崩溃。UI崩溃并带有错误消息:"加载共享库时无法打开SHSH:错误:libc.so.6:无法打开共享对象文件..."我已经搜索了此消息,但找不到与我的任何相关的东西Python脚本

我检查了Raspberry Pi的内存状态。Python过程在第32小时使用总内存的1/4。因此,这不是导致崩溃的内存。另外,我试图在没有监视器的情况下运行它,该监视器将在没有Python.curses的情况下启动假UI类。同样的崩溃发生在第32小时。

现在,我不了解脚本崩溃的原因。

我有8个覆盆子Pi作为种子箱的堆栈。我遇到了同样的错误,我从我的一个RASPI开发人员朋友中获得的最接近的正式答案是,一些较旧的内核与硬件有一些不兼容的错误。更新到最新的像素版本将解决您的问题。

最新更新