From: Hans Fugal Date: 2008-02-22T02:59:54+09:00 Subject: Re: Timers and Alarms On Feb 21, 8:42 am, "Eric I." wrote: > On Feb 21, 10:17 am, Hans Fugal wrote: > > > I want a program to wait for some moment in time, and resume operation > > at that moment. sleep is ruled out because it just counts cycles and is > > thrown off when my laptop suspends. > > What about a roll-your-own solution like: > > def my_sleep(interval, granularity = 60) > end_time = Time.now + interval > > remaining = end_time - Time.now > while granularity < remaining > sleep granularity > remaining = end_time - Time.now > end > > sleep remaining > end It's going to have to be something like this I think. I don't know how much impact waking every so often (about once per second in my situation) will have on power usage, but I see now that even setitimer in C suffers the same problem sleep does with laptop suspend.