This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: work around clocks with low resolution (uuid.py)
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: loewis Nosy List: loewis, nnorwitz, ocean-city
Priority: release blocker Keywords: patch

Created on 2006-08-17 10:44 by ocean-city, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
uuid.patch ocean-city, 2006-08-17 10:44
Messages (5)
msg50925 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2006-08-17 10:44
This patch improves workaround clocks with low
resolution yielding duplicate UUIDs. (rev51307)

Currently, windows buildbot is failing due to this bug.
http://www.python.org/dev/buildbot/trunk/x86%20XP%20trunk/builds/1390/step-test/0

Traceback (most recent call last):
  File
"C:\buildbot_py25\trunk.mcintyre-windows\build\lib\test\test_uuid.py",
line 381, in test_uuid1
    equal(len(uuids.keys()), 1000)
AssertionError: 998 != 1000

This happens because on this code (Lib/uuid.py),

   if timestamp == _last_timestamp:
       timestamp += 1
   _last_timestamp = timestamp

if timestamp is same value more than 3 times....

   timestamp == X and _last_timestamp != X:
       timestamp <- X + 1 and _last_timestamp <- X + 1

   timestamp == X: (again)
       timestamp != _last_timestamp, so timestamp is
       still X

   timestamp == X: (again)
       timestamp != _last_timestamp, so timestamp is
       still X (duplicated timestamp!)
       
I fixed this bug with attached patch.

# also fixed probably typo in test_uuid.py
msg50926 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2006-08-17 19:00
Logged In: YES 
user_id=1200846

Sorry, my explanation was wrong.

timestamp == X and _last_timestamp != X:
timestamp remains X, and _last_timestamp becomes X

timestamp == X: (again)
timestamp == _last_timestamp, so timestamp and
_last_timestamp becomes X + 1.

timestamp == X: (again)
timestamp != _last_timestamp, so timestamp remains X
(duplicated timestamp!)
msg50927 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-08-17 20:05
Logged In: YES 
user_id=21627

From inspection, the patch looks right to me (although i
haven't tested it). I think it should go into 2.5.
msg50928 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-08-18 03:36
Logged In: YES 
user_id=33168

Thanks for the patch!

Assuming this fixes the problem on Windows, someone please
test this and check it in.  Don't forget, head and 2.5
branch.  Needs updates to Misc/{NEWS,ACKS}
msg50929 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-08-18 03:48
Logged In: YES 
user_id=21627

Thanks for the patch. Committed as r51353 and r51354.
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43843
2006-08-17 10:44:28ocean-citycreate