imaplib send problem on BSD-style OSs
Piers Lauder
piers at cs.su.oz.au
Tue Nov 27 20:04:52 EST 2001
On Tue, 27 Nov 2001 13:50:47 -0800, Douglas Wiegley wrote:
>
> Hello. I'm not sure if this is the right place to address
> this email, so please let me know if I should be sending this
> elsewhere (found your email address at the top of imaplib.py).
>
> Having a slight problem with the imaplib.append() function
> with large messages. Basically, this line:
>
> 636: self.sock.send('%s%s' % (data, CRLF))
>
> doesn't always write all of the data and instead returns a
> number of bytes that is less than what you give it (similar
> to unix send()). I ended up needing a small while loop that
> calls send multiple times to ensure that all the data is
> sent...
>
> This is on FreeBSD 4.3. Please let me know if I'm doing
> something wrong...
>
> doug
No, it's a bug/feature in the socket module - hopefully fixed in a future
release. For an immediate work-around, sub-class IMAP4 and override
with the following version of send:
import imaplib
class IMAP4(imaplib.IMAP4):
def send(self, data):
"""Send data to remote."""
bytes = len(data)
while bytes > 0:
sent = self.sock.send(data)
if sent == bytes:
break # avoid copy
data = data[sent:]
bytes = bytes - sent
Hope that helps...
More information about the Python-list
mailing list