[Pymilter] really long processing

Stuart D. Gathman stuart at bmsi.com
Tue May 11 14:20:07 EDT 2004


On Tue, 11 May 2004, Eric S. Johansson wrote:

> that also raises the question.  Is pymilter single threaded?  It 
> shouldn't be a problem because I do use file locking to control access 
> to various important files but I'm wondering if that is sufficient in 
> the milter environment

pymilter is multi-threaded.  There can be thousands of mail connections
in progress - depending on memory and sendmail configuration.  I
routinely see hundreds.  By using the "stackless" python VM (which
uses linked lists for stack frames instead of allocating a fixed stack
area per thread), you can support hundreds of thousands of simultaneous
connections.

If all access to a resource is from threads within the Python VM, then
it is much more efficient to use a semaphore:

import thread
_lock = thread.allocate_lock()	# _lock in some global dictionary (e.g. module)
...
try:
  _lock.acquire()
  ...
finally:
  _lock.release()

Even when using a file lock for external processes, it is much more
efficient to first acquire a semaphore for internal threads before 
acquiring the external file lock.

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




More information about the Pymilter mailing list