[Pymilter] milter multiprocess (or multithread)
Marco
falon at ruparpiemonte.it
Tue Dec 10 03:06:12 EST 2019
Hello Stuart,
On 10/12/2019 02:51, Stuart D. Gathman wrote:
> On Mon, 9 Dec 2019, Marco wrote:
>
>> All works fine as expected. But with *threads* only, it seems that the
> You should verify that runmilter returns on SIGTERM by adding another
> print immediately after Milter.runmilter().
yes, I verified this. Even with a "print" just after the runmilter, no
output has been printed out after SIGTERM:
# ../venv/bin/python3 milter-template.py
2019Dec10 08:33:05 milter startup
Terminated
#
The code:
[...]
Milter.runmilter("myfilter",socketname,timeout)
print("%s Just after runmilter: bms milter shutdown" %
time.strftime('%Y%b%d %H:%M:%S'))
logq.put(None)
bt.join()
print("%s bms milter shutdown" % time.strftime('%Y%b%d %H:%M:%S'))
[...]
>> 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
Interesting. You say "Threads may still be useful, but you may need to
provide an alternate means of causing graceful shutdown.
You may find the multiprocessing module useful."
Ok, this is the only solution that I found to obtain a graceful
shutdown. So I suppose there is no way to have a graceful shutdown with
threading in pymilter.
There is not a Milter.Milter stop(self) function to print something when
SIGTERM or other signal happens, and then stop :(
Thank you for the clarification.
Anyway pymilter is the best for me. I'm surprised about the power of
this package! Thank you to share this.
Marco
More information about the Pymilter
mailing list