[PATCH 8/8] Create new connections with a timeout

Ethan Glasser-Camp ethan at betacantrips.com
Tue Dec 28 11:46:25 GMT 2010


From: Ethan Glasser-Camp <ethan at jonah-hex.(none)>

imaplib2 does not use socket, so does not know about the
defaulttimeout we set based on the config. Instead, we explicitly pass
the default timeout.
---
 offlineimap/imapserver.py |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py
index 3820fbe..ce551a9 100644
--- a/offlineimap/imapserver.py
+++ b/offlineimap/imapserver.py
@@ -20,7 +20,7 @@ from offlineimap import imaplib2, imaplibutil, imaputil, threadutil
 from offlineimap.ui import UIBase
 from offlineimap.accounts import syncfolder
 from threading import *
-import thread, hmac, os, time
+import thread, hmac, os, time, socket
 import base64
 
 from StringIO import StringIO
@@ -264,15 +264,17 @@ class IMAPServer:
                 # Generate a new connection.
                 if self.tunnel:
                     UIBase.getglobalui().connecting('tunnel', self.tunnel)
-                    imapobj = UsefulIMAP4_Tunnel(self.tunnel)
+                    imapobj = UsefulIMAP4_Tunnel(self.tunnel, timeout=socket.getdefaulttimeout())
                     success = 1
                 elif self.usessl:
                     UIBase.getglobalui().connecting(self.hostname, self.port)
                     imapobj = UsefulIMAP4_SSL(self.hostname, self.port,
-                                              self.sslclientkey, self.sslclientcert)
+                                              self.sslclientkey, self.sslclientcert,
+                                              timeout=socket.getdefaulttimeout())
                 else:
                     UIBase.getglobalui().connecting(self.hostname, self.port)
-                    imapobj = UsefulIMAP4(self.hostname, self.port)
+                    imapobj = UsefulIMAP4(self.hostname, self.port,
+                                          timeout=socket.getdefaulttimeout())
 
                 imapobj.mustquote = imaplibutil.mustquote
 
-- 
1.7.1





More information about the OfflineIMAP-project mailing list