From Sami-Pekka.Hallikas at crescom.fi Tue Dec 13 07:24:44 2005 From: Sami-Pekka.Hallikas at crescom.fi (Sami-Pekka Hallikas) Date: Tue, 13 Dec 2005 14:24:44 +0200 Subject: [Pymilter] Signal handling of miltermodule Message-ID: <1126E6D5A7B2204FAC3E0AFC376A9C142EBE30@caldo.crescomhosting.net> 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 From stuart at bmsi.com Tue Dec 13 12:34:07 2005 From: stuart at bmsi.com (Stuart D. Gathman) Date: Tue, 13 Dec 2005 12:34:07 -0500 (EST) Subject: [Pymilter] Signal handling of miltermodule In-Reply-To: <1126E6D5A7B2204FAC3E0AFC376A9C142EBE30@caldo.crescomhosting.net> Message-ID: On Tue, 13 Dec 2005, Sami-Pekka Hallikas wrote: > Is it possible to use signal handling with milter module? No. The libmilter C library eats them. In some systems, it is possible to direct signals to a particular thread (e.g. a Python thread). But this is not available everywhere. This is a posix limitation. > 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... We could provide a command program that connects to a socket, like rndc for named. Or we could check the timestamp on the config file. > Is it possible to miltermodule to pass those signals to main thread? Not portably. However, if you want to have an alarm in your milter, you can create a thread that sleeps and then posts a semaphore (all in Python). > And thanks for miltermodule anyway, it has been very nice to > use python to process mails. Thank you. I agree. -- Stuart D. Gathman 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. From stuart at bmsi.com Tue Dec 13 14:51:40 2005 From: stuart at bmsi.com (Stuart D. Gathman) Date: Tue, 13 Dec 2005 14:51:40 -0500 (EST) Subject: [Pymilter] Signal handling of miltermodule In-Reply-To: Message-ID: On Tue, 13 Dec 2005, Stuart D. Gathman wrote: > On Tue, 13 Dec 2005, Sami-Pekka Hallikas wrote: > > > Is it possible to use signal handling with milter module? > > No. The libmilter C library eats them. In some systems, it is > possible to direct signals to a particular thread (e.g. a Python thread). But > this is not available everywhere. This is a posix limitation. Another possibility is to use a pure Python implementation of libmilter. The difficulty is that there is no official documentation of libmilter protocol (other than source code). So it is still subject to change without notice (assuming that libmilter will work around any incompatibilities). -- Stuart D. Gathman 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. From stuart at bmsi.com Fri Dec 23 12:47:52 2005 From: stuart at bmsi.com (Stuart D. Gathman) Date: Fri, 23 Dec 2005 12:47:52 -0500 (EST) Subject: [Pymilter] Re: milter-0.8.4 In-Reply-To: Message-ID: On Fri, 23 Dec 2005, Stuart D. Gathman wrote: > It seems I have missed something. setup.py import Milter to get > the current version. It needs to append current directory to > PYTHONPATH. I missed testing the build on a system that has never > had milter installed. Actually, it is getting Milter.py from the build directory. The problem is that milter.so has not been built yet. I think I need to create a separate module with the version that __init__.py can import. -- Stuart D. Gathman 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. From stuart at bmsi.com Fri Dec 23 16:09:51 2005 From: stuart at bmsi.com (Stuart D. Gathman) Date: Fri, 23 Dec 2005 16:09:51 -0500 (EST) Subject: [Pymilter] Re: milter-0.8.4 In-Reply-To: <43AC5B82.1030404@plainscraft.com> Message-ID: On Fri, 23 Dec 2005, Stephen Figgins wrote: > ImportError: /usr/lib/python2.2/site-packages/milter.so: undefined > symbol: smfi_insheader Older versions of sendmail/libmilter did not have smfi_insheader. Looks like you need sendmail-8.13 for smfi_insheader. I'll see if I can come up with some ifdefs to handle sendmail-8.12. Otherwise, I'll update the BuildRequires to sendmail-8.13 -- Stuart D. Gathman 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.