title: Set a script to suspend and resume after a calculated amount of time
body: <p>Updated below:</p>
  
  <p>I have a script which has a function I made that calculates the time to set my script to sleep for based on a few factors, which means the script might not need to run again for a half hour or it could be a few days.</p>
  
  <p>Now, I had thought that time.sleep(seconds) would set the program to sleep and then wake it up and run it again.</p>
  
  
  
  <pre><code>time.sleep(3600)
  runScriptAgain()
  </code></pre>
  
  <p>Apparently this doesn't do what I thought it did. Of course most things never seem to do what I think, the joys of learning!</p>
  
  <p>At any rate once I figured out that the script was never resuming I looked around for other ways to do this. Someone had mentioned <code>os.exec</code> but from my (very limited) knowledge it looks like that is used to run something else from within the script. Then I tried the <code>threading.Timer</code> function but that doesn't seem to do what I want either. Or I have no idea what I'm doing, which is even more likely. And then I've seen people mentioning threads and daemons and things that I have no idea about at all.</p>
  
  <p>I was thinking maybe a for loop but that seems pretty amateurish(pot meet kettle!), and I'm not sure how well that would even work(if at all). </p>
  
  <pre><code>timeToSleep = SleepValue()
  count = 0 
  while count &lt; timeToSleep:
      count + 1
      time.sleep(1)
  runscript()
  </code></pre>
  
  <p>So is there an easy way to set a script to stop running for a specific amount of time, run again, and then sleep until the next time? I figure there must be a pretty simple way to do this, but I really have no clue. I'm on Windows 7 using Python 3.2.3, and I've only been learning python for a few months now so anything complicated is likely to be outside my skill level.</p>
  
  <p>Updated:</p>
  
  <pre><code>def something():
      print('Hello!')
  
  def sleep():
      time.sleep(5)
      runscript()
  
  def runscript():
      something()
      sleep()
  
  runscript()
  </code></pre>
  
  <p>Ok, that's how my code is currently setup. I tried it with this simple code and it seems the problem is that it just never wakes up? I'm not really sure what's going on. I thought it would call the first function, print the item, then sleep for 5 seconds, and repeat ad naseum. Maybe somebody can explain how I should be doing that.</p>
  
  <p>Thanks!</p>