[Pymilter] uniqueID()

Stuart D Gathman stuart at bmsi.com
Mon Aug 15 18:06:22 EDT 2011


On 08/13/2011 06:44 PM, Kyle Oetken wrote:
> In the example code this section assigns a unique ID to the milter instance:
>
> def__init__(self):# A new instance with each new connection.
>      self.id  <http://self.id>  = Milter.uniqueID()# Integer incremented with each call.
> In my testing it appears that the Milter.uniqueID appears to assign an 
> ID to each specific tcp connection. As a result, if multiple messages 
> are sent over that tcp connection each message will have the same 
> uniqueID. Is there a good way to assign a unique ID to a particular 
> message within the tcp connection?
You could assign an id within envfrom also (or instead).  However, since 
the tcp connection is a single thread,  I would recommend simply 
incrementing a count in envfrom (no need for locking as with uniqueID).  
You can concatenate the connection id and message index to form an id 
unique for that milter run.  Note that uniqueID starts over each time 
you start milter, it is not something you can use for Message-ID.  You 
could count milter startups in a file, and prepend that to connection id 
and mail from count to form a unique id.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gathman.org/pipermail/pymilter/attachments/20110815/ab1f1dc1/attachment.html>


More information about the Pymilter mailing list