Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAvoid busy waiting in ioloop when system time is skipped forward #1290
Conversation
This comment has been minimized.
This comment has been minimized.
|
Instead of an arbitrary threshold, I wonder if it would be better to do something like this:
If I've got the math right, this is a constant-time version of the current semantics (including the fact that next_timeout always advances by a multiple of callback_time, although I don't know how important it is to preserve this behavior). Also, systems that experience large NTP adjustments may be better served by configuring the IOLoop to use time.monotonic() instead of time.time(). |
This comment has been minimized.
This comment has been minimized.
|
ok, I will try your solution and report back! |
880152c
to
70ef0b1
…hanges of the system time differently: * calculating next timeout value directly while advancing by a multiple of callback_time * when the system time changes, jumps into the future make the _schedule_next method do a busy wait. * on slow machines (RPi), jumps of a few months into the future can block the loop for a few minutes => added a check for big differences in current system time and the current value of the next scheduled timeout On a first boot of an older RPi image, tornado sometime starts before the date&time were updated through NTP, hence blocking the ioloop for several minutes.
This comment has been minimized.
This comment has been minimized.
|
I used the code you suggested with small changes. As in the original code, the _next_timeout is increased when it is smaller or equal to the current time. I made the code calculate the next_timeout directly by tweaking your formula a bit. The new value of next_timeout is larger than current_time and smaller or equal to current_time + callback_time_sec. |
Avoid busy waiting in ioloop when system time is skipped forward
Should hopefully help with freezing/blocking issues upon first connect with the net on the Pi, more tests needed.
nosyjoe commentedDec 29, 2014
=> added a check for big differences in current system time and the current value of the next scheduled timeout
On a first boot of an older RPi image, tornado sometimes starts before date&time gets updated through NTP, hence blocking the ioloop for several minutes.