--- D:/apps/Python26/Lib/email/utils-trunk.py Tue Aug 04 00:20:31 2009 +++ D:/apps/Python26/Lib/email/utils.py Tue Aug 04 00:05:43 2009 @@ -172,6 +172,19 @@ +try: + from threading import Lock +except ImportError: + from dummy_threading import Lock +_next_number_lock = Lock() + +def _gen_next_number(): + while True: + for number in xrange(100000): + yield number + +_next_number = _gen_next_number().next + def make_msgid(idstring=None): """Returns a string suitable for RFC 2822 compliant Message-ID, e.g: @@ -183,13 +196,14 @@ timeval = time.time() utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval)) pid = os.getpid() - randint = random.randrange(100000) + with _next_number_lock: + seqint = _next_number() if idstring is None: idstring = '' else: idstring = '.' + idstring idhost = socket.getfqdn() - msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, idhost) + msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, seqint, idstring, idhost) return msgid