title: python script crashes after long time running
body: <p>I have a python 2.7 script running on a Raspberry Pi 3. </p>
  
  <pre><code>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"
  </code></pre>
  
  <p>Basely what it does is to send a message through UART to a chip, obtain response message, update log files and print it onto the UI (a UI displayed on monitor created by python curses). It does this every 1 second.</p>
  
  <p>The script has no bug running for 32 hours then it crashes. The UI is crashed and covered with error message:" cannot open shsh: error while loading shared libraries: libc.so.6 : cannot open shared object file..." I have googled this message but didn't find anything related to my python script</p>
  
  <p>I have checked the memory status of the Raspberry Pi. The python process uses about 1/4 of the total memory at the 32th hour. So it is not the memory causing crash. Also, I have tried to run it without a monitor, which will launch a fake UI class without python.curses. same crash happened at the 32th hour.</p>
  
  <p>Now, I am out of idea about why the script crashes. </p>