summaryrefslogtreecommitdiff
path: root/qpid/python
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2010-03-26 12:34:46 +0000
committerRafael H. Schloming <rhs@apache.org>2010-03-26 12:34:46 +0000
commit93b56d27e0752d5195c98a7d0715a2d83ce4b42a (patch)
treee4b93d1279780227392f3843cfd14a83b029be01 /qpid/python
parentf6ecda4db707b4bbbf8d770d2883d7a3568c432e (diff)
downloadqpid-python-93b56d27e0752d5195c98a7d0715a2d83ce4b42a.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@927803 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
-rw-r--r--qpid/python/qpid/datatypes.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/qpid/python/qpid/datatypes.py b/qpid/python/qpid/datatypes.py
index 61643715e4..e4cbcb7f10 100644
--- a/qpid/python/qpid/datatypes.py
+++ b/qpid/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