From: Nicolas S. <nic...@la...> - 2016-07-29 03:21:50
|
Hi Piers, I've done debug sessions to understand why offlineimap can hang. It appears one of our thread might hang waiting for imaplib2 which never returns a value. This happens when I reach the (undocumented) maximum number of connections to my IMAP server. I guess they limit connections based on the public IP or similar. It looks like IMAP servers "handle" this case in quite different ways. I believe that Gmail drops a previously existing connection. imap.laposte.net will hold the connection without ever returning a welcome message. This sucks hard but I wonder other servers have similar behaviour. Hence, imaplib2 is blocked at line 396 in __init__: self.welcome = self._request_push(name='welcome', tag='continuation').get_response(...) I wonder if imaplib2 should not assume a response within the global threading.TIMEOUT_MAX range which is "very" long (considered infinite). I know that socket.setdefaulttimeout() can handle this, too. We currently allow the users to configure a value for this. However, both are expected large enough to avoid reaching the timeout while it should not. IOW, I think some very special cases at decisive steps might use a short timeout while waiting for a response. The above line 396 falls into this case. We know that the time required for a welcome message is definetly shorter than for downloading/fetching a mail. So, we might like to add a "max_timeout" argument to get_response() at line 191. By using short timeouts when applicable, we would avoid hangs or long waits. Also, I wonder that waiting for the welcome message might not be the only one case. Some IMAP servers might behave in a similar way for other limits: e.g. at authentication time to limit connections in a per-account basis. Thoughts? -- Nicolas Sebrecht |