[Imaplib2-devel] Gmail: downloading the rest of the mails

Piers Lauder piers at janeelix.com
Thu Oct 13 09:38:10 UTC 2011


On Thu, 13 Oct 2011 08:16:02 +0200, Sebastian Spaeth wrote:
  > 
  > On Mon, 10 Oct 2011 22:11:32 +1100, Piers Lauder <piers at janeelix.com> wrote:
  > > You could try tinkering with the code around the "read 0" message. Try
  > > making the loopcount longer, and see if that avoids the problem. At
  > > the moment it tries 5 times, with a 0.1 sec sleep after each read 0,
  > > which is 1/2 second. I guess its interesting that the read doesn't
  > > raise an exception for broken socket, so it might be worthwhile hanging
  > > around longer.
  > > 
  > > Is this by any chance an SSL socket? If so it maybe the SSL code that
  > > isn't handling the socket disconnection properly, though that does
  > > seem unlikely.
  > > 
  > > Anyway, I still think a "read 0" should mean EOF, so that restarting a new
  > > connection is the correct response.
  > 
  > Yes, as these are all gmail connections, they are all SSL sockets.
  > 
  > It could well be that gmail simply delays sending for some time, so
  > imaplib2 trips over the 5*0.1 sec limit. Killing the connection and
  > re-establishing will of course work, unless gmail considers that abusive
  > and locks us out.

If gmail is just delaying, that shouldn't yield a "read 0" - the
O/S should just delay the read until there is data to pass along. In
my experience, a "read 0" always means a driver at the O/S level has
detected a dropped connection.

Anyway, first off - try lengthening the timeout (as well as restarting the connection after any exception raised by the loop timing out).

Piers.





More information about the OfflineIMAP-project mailing list