From 6e9d609b0edea3daab64fcd8fbf7a1bb0f0b3146 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Fri, 26 Mar 2010 12:34:46 +0000 Subject: 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 --- python/qpid/datatypes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'python') 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 -- cgit v1.2.1