raspberry pi - Can this Python script cause an R Pi freeze? -


the python script below seems cause raspberry pi 3 freeze after few hours when running in background. might file operations in while loop cause memory leak?

i'm starting script via line below in /etc/rc.local

(sleep 10;nohup python3.4 -u /home/pi/soundserve.py /home/pi/soundserve.output.txt 2>&1) &

thanks in advance help!

marc

script:

import os.path import pygame import time  def getparam(name):     f = open("/home/pi/"+name,"r")     lines = f.readlines()     f.close()     if lines:         f = open("/home/pi/"+name,"w")         f.write("")         f.close()         print (lines[0])         return lines[0]     else:         return("none")  def loopsound(n,name):     global lines     x in range(0, n):         pygame.mixer.init()         pygame.mixer.music.load("/home/pi/sounds/"+name+".mp3")         pygame.mixer.music.play(0)          while pygame.mixer.music.get_busy() == true:#            continue             param = getparam("quitsound")             if "stop" in param:                 pygame.mixer.quit()                 lines[:] = []                 break             else:                 time.sleep(1)                 continue         pygame.mixer.quit()         if "stop" in param:break         time.sleep(2)     while true: # main loop     # read last line file     f = open("/home/pi/soundqueue.txt","r")     lines = f.readlines()     f.close()     if lines:         f = open("/home/pi/soundqueue.txt","w")         f.write("")         f.close()         line in reversed(lines):             if line != "\n":                 print (line)                 line = line.strip('\n')                 data = line.split(",")                 if os.path.isfile('/home/pi/sounds/'+str(data[0])+'.mp3'):                     loopsound(int(data[1]),str(data[0])) 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -