help using smptd
Edward Elliott
nobody at 127.0.0.1
Sun May 14 23:50:42 EDT 2006
Edward Elliott wrote:
> import smtpd
>
> class SMTPProxy (smtpd.SMTPServer):
> def process_message (self, peer, mailfrom, rcpttos, data):
> # my code here
>
> proxy = SMTPProxy (listen_addr, relay_addr)
> # now what?
Update: I think I've solved it. SMTPServer registers with asyncore, so the
'now what' to handle connections is this:
asyncore.loop()
I tried that once before I posted without success, however I think I had
accidentally closed the socket already.
Now a follow-up question: does anyone know the purpose of the timeout
parameter to loop()? The asyncore docs say this:
"The timeout argument sets the timeout parameter for the appropriate
select() or poll() call, measured in seconds; the default is 30 seconds."
According to the select man page, timeout determines how long it blocks
before returning. But AFAICT, asyncore.loop() runs forever (as long as a
channel is open) no matter how long select blocks. What's the point of
passing a timeout for select when loop just calls it again every time it
returns?
--
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
More information about the Python-list
mailing list