[Patches] [ python-Patches-1607149 ] bug# 1607041: Condition.wait timeout fails on clock change

SourceForge.net noreply at sourceforge.net
Sun Dec 3 08:11:09 CET 2006


Patches item #1607149, was opened at 2006-12-01 23:32
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1607149&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: BC (hashstat)
Assigned to: Nobody/Anonymous (nobody)
Summary: bug# 1607041: Condition.wait timeout fails on clock change

Initial Comment:
This patch if for bug# 1607041.

If the system clock is adjusted after Condition.wait is called with a timeout, the timeout does not expire as expected. This appears to be due to the threading.Condition class using the system clock to calculate the timeout expiration without taking system clock changes into account.

No matter what timeout is used, setting the system clock ahead reduces or eliminates the wait while setting the system clock back increases the wait.  So if the clock is set back one hour in the middle of a 1 microsecond wait (c.wait(1)), wait will return in an hour and 1 microsecond rather than after 1 microsecond.

This patch modifies the Condition classes wait method to check for variations in the clock between calls to sleep and ajust for abnormalities.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2006-12-03 08:11

Message:
Logged In: YES 
user_id=21627
Originator: NO

It would be better if this was based on a monotonic clock if available on
the system (such as the  POSIX CLOCK_MONOTONIC argument to clock_gettime).
"Guessing" jumps in the time is inherently unreliable; in your code, you
won't notice changes that involve less than 10s.

Notice that the same problem exists for Thread.join; it would be good if
they were fixed together.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1607149&group_id=5470


More information about the Patches mailing list