python script crashes after long time running
Asked Answered
M

1

7

I have a python 2.7 script running on a 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"

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.

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

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.

Now, I am out of idea about why the script crashes.

Milkmaid answered 15/12, 2016 at 18:32 Comment(6)
@StevenRumbalski yes, that is a typo.Milkmaid
Which version of libc are you using, or is it glibc?Jerkin
@Jerkin i dont know much about that. All I did was load a python script onto a raspberry pi 3 with Rasabian on it. And I didn't do anything about the linux system.Milkmaid
check the output of lsof -i $PID every few hours, is it opening too many file descriptors? Is the error exit code number 24?Jerkin
Are you still having this issue? Do you have an answer to jmunsch's question? I can add a bounty to your question to make it get attention, but I want to make sure that you are around to respond to questions.Sunlight
It appears the OP has abandoned this question and is not responding to clarifying questions in the comments.Sunlight
P
1

I have a stack of 8 raspberry pi's working as a seedbox. I had encountered the same error and the nearest official answer that i got from one of my raspi developer friend was that some older kernels have some incompatible bugs with the hardware. Updating to the latest Pixel version would solve your issue.

Picro answered 1/6, 2017 at 5:55 Comment(1)
Thanks for your suggestion. I have solved the problem by changing my program's structure. even though the program does not crash now, but it runs much slower now.Milkmaid

© 2022 - 2024 — McMap. All rights reserved.