--- D:/apps/Python26/Lib/email/utils-trunk.py Tue Aug 04 00:20:31 2009 +++ D:/apps/Python26/Lib/email/utils.py Fri Aug 07 16:40:16 2009 @@ -172,10 +172,23 @@ +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: - <20020201195627.33539.96671@nightshade.la.mastaler.com> + <20020201195627.137.33539.96671@nightshade.la.mastaler.com> Optional idstring if given is a string used to strengthen the uniqueness of the message id. @@ -184,12 +197,14 @@ 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@%s>' % (utcdate, pid, randint, seqint, idstring, idhost) return msgid