[ mailman-Patches-707624 ] SMTPDirect doesn't use persistent SMTP connections
Patches item #707624, was opened at 2003-03-21 18:26 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=300103&aid=707624&group_id=103 Category: mail delivery Group: Mailman 2.1 Status: Open Resolution: None Priority: 5 Submitted By: Jesús Cea Avión (jcea) Assigned to: Nobody/Anonymous (nobody) Summary: SMTPDirect doesn't use persistent SMTP connections Initial Comment: Mailman 2.1.1 here. "/Mailman/Handlers/SMTPDirect.py" is suppose to reuse SMTP connections up to "mm_cfg.SMTP_MAX_SESSIONS_PER_CONNECTION" different messages. Nevertheless, it's NOT the case: "SMTPDirect" drop the connection when send each message. This is an important CPU hog when mailman has a long queue spool. Here is the patch (sorry, I can't send it as an attach, shame on me). It's fairly trivial :
Index: SMTPDirect.py =================================================================== RCS file: /opt/src/cvsroot/mailman/Mailman/Handlers/SMTPDirect.py,v retrieving revision 1.1.1.5 retrieving revision 1.1.1.5.2.1 diff -u -u -r1.1.1.5 -r1.1.1.5.2.1 --- SMTPDirect.py 2003/03/20 10:14:58 1.1.1.5 +++ SMTPDirect.py 2003/03/21 16:48:31 1.1.1.5.2.1 @@ -48,7 +48,7 @@ # Manage a connection to the SMTP server -class Connection: +class ConnectionClass: def __init__(self): self.__connect() @@ -79,7 +79,15 @@ def quit(self): self.__conn.quit() + def rset(self) : + self.__conn.rset() + def __del__(self) : + self.quit() + + +Connection=ConnectionClass() + def process(mlist, msg, msgdata): recips = msgdata.get('recips') @@ -130,7 +138,7 @@ # This means at worst, the last chunk for which delivery was attempted # could get duplicates but not every one, and no recips should miss the # message. - conn = Connection() + conn = Connection try: msgdata['undelivered'] = chunks while chunks: @@ -147,7 +155,8 @@ raise del msgdata['undelivered'] finally: - conn.quit() + conn.rset() + # conn.quit() msgdata['recips'] = origrecips # Log the successful post t1 = time.time() <<<<< ----------------------------------------------------------------------
Comment By: Jesús Cea Avión (jcea) Date: 2003-03-24 08:33
Message: Logged In: YES user_id=97460 The proposed patch causes exceptions if space between messages is greater than SMTP timeout. Corrected patch (I still can't attach a file):
Index: SMTPDirect.py =================================================================== RCS file: /opt/src/cvsroot/mailman/Mailman/Handlers/SMTPDirect.py,v retrieving revision 1.1.1.5 retrieving revision 1.1.1.5.2.3 diff -u -r1.1.1.5 -r1.1.1.5.2.3 --- SMTPDirect.py 2003/03/20 10:14:58 1.1.1.5 +++ SMTPDirect.py 2003/03/24 07:11:32 1.1.1.5.2.3 @@ -48,7 +48,7 @@ # Manage a connection to the SMTP server -class Connection: +class ConnectionClass: def __init__(self): self.__connect() @@ -58,6 +58,15 @@ self.__numsessions = mm_cfg.SMTP_MAX_SESSIONS_PER_CONNECTION def sendmail(self, envsender, recips, msgtext): + try : + self.__conn.rset() + except : + try : + self.__conn.quit() + except : + pass + self.__connect() + try: results = self.__conn.sendmail(envsender, recips, msgtext) except smtplib.SMTPException: @@ -79,6 +88,11 @@ def quit(self): self.__conn.quit() + def __del__(self) : + self.quit() + + +Connection=ConnectionClass() def process(mlist, msg, msgdata): @@ -130,7 +144,7 @@ # This means at worst, the last chunk for which delivery was attempted # could get duplicates but not every one, and no recips should miss the # message. - conn = Connection() + conn = Connection try: msgdata['undelivered'] = chunks while chunks: @@ -147,7 +161,7 @@ raise del msgdata['undelivered'] finally: - conn.quit() + # conn.quit() msgdata['recips'] = origrecips # Log the successful post t1 = time.time() <<<<< ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=300103&aid=707624&group_id=103
participants (1)
-
SourceForge.net