python脚本在长时间运行后崩溃

fly*_*ade 7 python uart python-2.7 python-curses raspberry-pi3

我在Raspberry Pi 3上运行了一个python 2.7脚本.

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"
Run Code Online (Sandbox Code Playgroud)

基本上它的作用是通过UART向芯片发送消息,获取响应消息,更新日志文件并将其打印到UI(由python curses创建的监视器上显示的UI).它每1秒执行一次.

该脚本没有错误运行32小时然后崩溃.UI崩溃并覆盖了错误消息:"无法打开shsh:加载共享库时出错:libc.so.6:无法打开共享对象文件..."我搜索了这条消息,但没有找到任何与我相关的信息python脚本

我检查了Raspberry Pi的内存状态.python进程在第32小时使用大约1/4的总内存.所以不是导致崩溃的内存.此外,我试图在没有监视器的情况下运行它,这将启动一个没有python.curses的假UI类.同样的事故发生在第32个小时.

现在,我不知道脚本崩溃的原因.

小智 1

我有一堆 8 个树莓派作为种子箱。我遇到了同样的错误,我从我的一位 raspi 开发者朋友那里得到的最接近的官方答案是,一些较旧的内核存在一些与硬件不兼容的错误。更新到最新的 Pixel 版本可以解决您的问题。