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

时间:2016-12-15 18:32:14

标签: python python-2.7 uart raspberry-pi3 python-curses

我在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"

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

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

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

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

1 个答案:

答案 0 :(得分:1)

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