[Pymilter] milter multiprocess (or multithread)

Stuart D. Gathman stuart at gathman.org
Mon Dec 9 20:51:13 EST 2019


On Mon, 9 Dec 2019, Marco wrote:

> All works fine as expected. But with *threads* only, it seems that the milter 
> eats the sigterm signal. To be fast, if I have this milter-template.py:

To be precise, libmilter eats most signals.

> ====================================================================
> if False:
>  from multiprocessing import Process as Thread, Queue
> else:
>  from threading import Thread
>  from queue import Queue
> [...]
>  logq.put(None)
>  bt.join()
>  print("%s bms milter shutdown" % time.strftime('%Y%b%d %H:%M:%S'))
>
> if __name__ == "__main__":
>  main()
> ====================================================================
>
> when I terminate the milter, the "bms milter shutdown" never prints to 
> stdout.
>
> This is just a "cosmetic" issue, but it should nice to print a "milter 
> shutdown" when the milter stops as expected.

You should verify that runmilter returns on SIGTERM by adding another
print immediately after Milter.runmilter().

> If I well understand this is a limitation from libmilter interface. I don't 
> understand how to avoid this limit really. For instance, could I terminate 
> the milter sending a "stop" command?

I discuss this in https://pymilter.org/pymilter/index.html in "threading".
I'll be happy to add any addition info you uncover on user threads
with libmilter.  :-)

The libmilter docs discussion is here:
https://pymilter.org/pymilter/milter_api/overview.html#SignalHandling

-- 
 	      Stuart D. Gathman <stuart at gathman.org>
"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