[Pymilter] Signal handling of miltermodule

Sami-Pekka Hallikas Sami-Pekka.Hallikas at crescom.fi
Tue Dec 13 07:24:44 EST 2005


Is it possible to use signal handling with milter module?

It would be nice to give commands, like reload config
with SIGHUP, without quiting milter. I've got my handler
working just great without miltermodule, but when milter
is active it seems to eat all signals...

Here is sample code that illustrates my problem:
#!/usr/bin/env python2

import signal
import milter
from sys import exit
from time import sleep

def sigalrm(signal, frame):
        print "SIGALRM received"
        return

signal.signal(signal.SIGALRM, sigalrm)
print "fist 2 secs"
signal.alarm(2)
# Should wait only 2 secs, even we sleep for 300
# sleep time is long, for just to make my point
sleep(300)
print "next 2 secs"
signal.alarm(2)
sleep(300)

milter.setconn("inet:9876")
milter.register("sspamm")

print "last.. this hangs"
signal.alarm(2)
print "Press ^C to quit (needed multiple times?)"
# next line makes signals go away :(
milter.main()
print "Now ^C does not work at all if milter runned"
while 1: sleep(1)
print "before exit"
exit(0)

Code above works just fine if you comment milter.main() away.

Is it possible to miltermodule to pass those signals to main thread?


And thanks for miltermodule anyway, it has been very nice to
use python to process mails.

-- 
Crescom Oy / Sami-Pekka Hallikas              
Email: samipekka.hallikas at crescom.fi





More information about the Pymilter mailing list