title: How can I make my Python script run forever?
body: <p>I have a python script (excerpt shown below) that reads a sensor value.  Unfortunately, it runs only for 5 - 60 minutes at a time and then suddenly stops.  Is there a way I can efficiently make this run forever?  Is there any reason why a python script like this couldn't run forever on a Raspberry Pi, or does python automatically limit the duration of a script?</p>
  
  <pre><code> while True:
      current_reading = readadc(current_sensor, SPICLK, SPIMOSI, SPIMISO, SPICS)
      current_sensed = (1000.0 * (0.0252 * (current_reading - 492.0))) - correction_factor
  
      values.append(current_sensed)
      if len(values) &gt; 40:
             values.pop(0)
  
      if reading_number &gt; 500:
             reading_number = 0
  
      reading_number = reading_number + 1
  
      if ( reading_number == 500 ):
             actual_current = round((sum(values)/len(values)), 1)
  
             # open up a cosm feed
             pac = eeml.datastream.Cosm(API_URL, API_KEY)
  
             #send data
             pac.update([eeml.Data(0, actual_current)])
  
             # send data to cosm
             pac.put()
  </code></pre>