Forum: Ruby on Rails sleep function duration changes when system clock is modifie

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jan (Guest)
on 2007-02-12 21:46
(Received via mailing list)
My problem is related to the behaviour of sleep function. If, during
the execution of sleep function, I change the system clock of my PC,
sleep function will not recover from sleeping when it should.

Example:

My controller:

def index
  logger.info "Start sleeping at:"+Time.now.to_s
  sleep 5
  logger.info "Sleeping finished at:"+Time.now.to_s
end

Everythink works well if I don't change the system time during the
execution of sleep function.
However, if during the execution of sleep function I shift the system
time, let's say 1 minute back, I'll need to wait 1 minute and 5
seconds until the sleep function finishes.

I'd need to force sleep function to sleep always 5 seconds, even if
the system time changes during the call of the sleep function.

If I try somethink similar in pure ruby (no rails), everythink works
as expected, I can change system time without any consequences to the
behaviour of sleep function.

I am using Rails 1.2.1 under WinXP.

Thanks for your help.
Alex W. (Guest)
on 2007-02-12 22:10
Jan wrote:
> My problem is related to the behaviour of sleep function. If, during
> the execution of sleep function, I change the system clock of my PC,
> sleep function will not recover from sleeping when it should.

While odd, why is this really a problem?  You shouldnt be manually
changing the system clock very often.
Jan (Guest)
on 2007-02-12 23:00
(Received via mailing list)
The server application will be running on customer's PC and the sleep
function is used in a background thread. In these conditions, the
manual change of system clock may happen and I would'nt like if this
freezed the background thread.
Robert W. (Guest)
on 2007-11-06 16:46
Bump...I am also experiencing this problem with Fedora Core 6 & 7

http://www.ruby-forum.com/topic/123178#new
http://www.ruby-forum.com/topic/130593#new
This topic is locked and can not be replied to.