You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2010/03/26 13:34:47 UTC

svn commit: r927803 - /qpid/trunk/qpid/python/qpid/datatypes.py

Author: rhs
Date: Fri Mar 26 12:34:46 2010
New Revision: 927803

URL: http://svn.apache.org/viewvc?rev=927803&view=rev
Log:
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

Modified:
    qpid/trunk/qpid/python/qpid/datatypes.py

Modified: qpid/trunk/qpid/python/qpid/datatypes.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/datatypes.py?rev=927803&r1=927802&r2=927803&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/datatypes.py (original)
+++ qpid/trunk/qpid/python/qpid/datatypes.py Fri Mar 26 12:34:46 2010
@@ -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



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org