diff options
author | Rafael H. Schloming <rhs@apache.org> | 2010-03-26 12:34:46 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2010-03-26 12:34:46 +0000 |
commit | 6e9d609b0edea3daab64fcd8fbf7a1bb0f0b3146 (patch) | |
tree | 9c33ebfe327e1ef01380d0001d48e237c1827c2c | |
parent | e8194a222b773609e310d4c30a4ab9ecb1c8e151 (diff) | |
download | qpid-python-6e9d609b0edea3daab64fcd8fbf7a1bb0f0b3146.tar.gz |
form compat uuid generation, use a random number generator that is initialized with the pid, hostname, and time; without this we can get duplicates if multipleprocesses startup and generate UUIDs simultaneously
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@927803 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | python/qpid/datatypes.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/python/qpid/datatypes.py b/python/qpid/datatypes.py index 61643715e4..e4cbcb7f10 100644 --- a/python/qpid/datatypes.py +++ b/python/qpid/datatypes.py @@ -290,9 +290,11 @@ try: def random_uuid(): return uuid.uuid4().get_bytes() except ImportError: - import random + import os, random, socket, time + rand = random.Random() + rand.seed((os.getpid(), time.time(), socket.gethostname())) def random_uuid(): - bytes = [random.randint(0, 255) for i in xrange(16)] + bytes = [rand.randint(0, 255) for i in xrange(16)] # From RFC4122, the version bits are set to 0100 bytes[7] &= 0x0F |