

Stateless, fault-tolerant scheduling using randomness - hooande
http://tech.backtype.com/stateless-scheduling-through-randomness

======
JoachimSchipper
Of course, you could also randomly generate a time, then sleep for that long.
This gives you significantly more control (you can easily specify "wait at
least an hour" or "wait at most 48 hours") and is less resource-intensive. (Of
course, "wait at least an hour" is not a good idea if your program crashes all
the time.)

Still, nice.

------
queensnake
??? Why not just set it to run at say 1am? Stateless, simple. Or did I miss
something?

    
    
      def deleting_thread():  
        while True:  
          # 10 minutes
          time.sleep(10 * 60) 
          # pseudocode
          if 01:00 <= time() and time() < 01:10:
              deleteFromSolrAndOptimize()
    

And no I'm not creating an account to tell this guy so on his blog.

------
moe
While this is an interesting hack it seems like a very strange approach to the
problem at hand.

If you don't care how often your function runs then why not just rely on the
system clock and maintain a "lastrun"-variable?

~~~
headsling
because that would violate his 'stateless' requirement

~~~
moe
True, I should've had my coffee first.

