Caio Brentano wrote:
Ok... I promise this is the last email! :-)

I got a better solution.

Just put "random.seed()" before "bytes = [random.randint(0, 255) for i in
xrange(16)]" in the file "qpid-0.6/python/qpid/datatypes.py" (line 296).

Nice catch! It's always disconcerting when UUIDs aren't unique. I actually ran into the same issue the other day except it was with independent processes that were simultaneously started. The problem is that the random number generator seeds itself with the current time by default, and so if the processes start simultaneously you'll get the same random numbers. I've updated the code on trunk to seed itself based on a hash of the current time, the PID, and the hostname. Hopefully that will provide a bit more uniqueness:

  ...
  import os, random, socket, time
  rand = random.Random()
  rand.seed((os.getpid(), time.time(), socket.gethostname()))
  def random_uuid():
    bytes = [rand.randint(0, 255) for i in xrange(16)]
    ...

--Rafael


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to