[Mailman-Developers] run_queue bug

Scott scott@chronis.icgroup.com
Tue, 4 Aug 1998 21:42:41 -0400


I don't know all the specifics of why this is happening (seems like
some system librarires do a seek while coercing a socket struct to a
FILE *?), but the following patch takes use of .makefile() out of
smtplib.py and fixes the problem.

scott


*** /home/mailman/Mailman/smtplib.py	Tue Aug  4 00:05:27 1998
--- /home/scott/smtplib.py	Tue Aug  4 21:36:19 1998
***************
*** 45,57 ****
  class SmtpConnection:
      def __init__(self, host=''):
  	self.host = host
- 	self._file = None
  	self.connect()
  
      def connect(self):
  	self._sock = socket(AF_INET, SOCK_STREAM)
  	self._sock.connect(self.host, SMTP_PORT)
- 	self._file = self._sock.makefile('r')
  	self.getresp()
  
      def helo(self, host):
--- 45,55 ----
***************
*** 103,109 ****
  
  # Private crap from here down.
      def getline(self):
! 	line = self._file.readline()
  	if not line: raise EOFError
  	if line[-2:] == CRLF: line = line[:-2]
  	elif line[-1:] in CRLF: line = line[:-1]
--- 101,114 ----
  
  # Private crap from here down.
      def getline(self):
!         line = ""
!         while 1:
!             c = self._sock.recv(1)
!             if not c:
!                 break
!             line = line + c
!             if c == "\n":
!                 break
  	if not line: raise EOFError
  	if line[-2:] == CRLF: line = line[:-2]
  	elif line[-1:] in CRLF: line = line[:-1]



On Tue, Aug 04, 1998 at 08:03:26PM -0400, Scott wrote:
| 
| run_queue quits with the following traceback whenever i run it with
| python1.5.1 on an old ret hat linux box :(
| 
| scott
| 
| Traceback (innermost last):
|   File "/home/mailman/cron/run_queue", line 31, in ?
|     OutgoingQueue.processQueue()
|   File "/home/mailman/Mailman/OutgoingQueue.py", line 38, in
| processQueue
|     Utils.TrySMTPDelivery(recip,sender,text,full_fname)
|   File "/home/mailman/Mailman/Utils.py", line 199, in TrySMTPDelivery
|     con = smtplib.SmtpConnection(mm_cfg.SMTPHOST)
|   File "/home/mailman/Mailman/smtplib.py", line 49, in __init__
|     self.connect()
|   File "/home/mailman/Mailman/smtplib.py", line 54, in connect
|    self._file = self._sock.makefile('r')
| socket.error: (29, 'Illegal seek')
| 
| _______________________________________________
| Mailman-Developers maillist  -  Mailman-Developers@python.org
| http://www.python.org/mailman/listinfo/mailman-developers
|