[Pymilter] uniqueID()

Kyle Oetken oetkenky at hotmail.com
Wed Aug 31 00:57:02 EDT 2011


Stuart,

Thanks for you help.   Essentially I ended up adding the following to my code per you suggestion:

1)  In the "hello" function:
        self.conn_counter = None
2)  In the "envfrom" function:
         if self.conn_counter is None:
            self.conn_counter = 1
        else:
            self.conn_counter += 1

I think added appended this value to the Milter.uniqueID when logging.   It appears to do exactly what I needed.

Thanks again,

Kyle


Date: Mon, 15 Aug 2011 18:06:22 -0400
From: stuart at bmsi.com
To: pymilter at bmsi.com
Subject: Re: [Pymilter] uniqueID()



  


    
    
  
  
    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 = 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.

  


_______________________________________________
Pymilter mailing list
Pymilter at bmsi.com
http://www.bmsi.com/mailman/listinfo/pymilter 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gathman.org/pipermail/pymilter/attachments/20110831/55b2775e/attachment.html>


More information about the Pymilter mailing list