[Pymilter] Forking pymilter?

Stuart D. Gathman stuart at bmsi.com
Wed Oct 24 14:48:13 EDT 2007


On Wed, 24 Oct 2007, Dwayne Litzenberger wrote:

> On October 24, 2007 12:10:36 pm Andrew Azarov wrote:
> > Is there any way to make a forking python milter?
> 
> The milter API insists on having re-entrant, thread-safe milters.  I had 
> oh-so-much fun writing a milter that uses python-ldap, which isn't 
> thread-safe in any meaningful way.
> 
> If you need to do something complicated, it might be easier to make a milter 
> that communicates with a separate daemon process over a Unix domain socket.

I found it easy enough to wrap non-thread-safe APIs with mutexes from
the thread module.  I needed to do that with libdspam, for example.
If it comes up a lot, an @synchronized decorator would
be easy enough to do, if it isn't in 2.5 already (I'm still on 2.4).

Keeping all your data in the connection object makes the actual milter
code easy to keep threadsafe.

-- 
	      Stuart D. Gathman <stuart at bmsi.com>
    Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flammis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.




More information about the Pymilter mailing list