Anonymous avatar Anonymous committed 9ac8bd3

Moved SSL imports out of util, removed SSL-specific exceptions from the various socket_ functions.

Comments (0)

Files changed (2)

eventlet/greenio.py

         if e[0] == errno.EWOULDBLOCK or e[0] == errno.ENOTCONN:
             return 0
         raise
-    except util.SSL.WantWriteError:
-        return 0
-    except util.SSL.WantReadError:
-        return 0
 
 # winsock sometimes throws ENOTCONN
 SOCKET_CLOSED = (errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN)
         if e[0] in SOCKET_CLOSED:
             return ''
         raise
-    except util.SSL.WantReadError:
-        return None
-    except util.SSL.ZeroReturnError:
-        return ''
-    except util.SSL.SysCallError, e:
-        if e[0] == -1 or e[0] > 0:
-            return ''
-        raise
 
 
 def file_recv(fd, buflen, flags=0):
         self.fd.fd.flush()
 
 
+try:
+    from OpenSSL import SSL
+except ImportError:
+    class SSL(object):
+        class WantWriteError(object):
+            pass
+
+        class WantReadError(object):
+            pass
+
+        class ZeroReturnError(object):
+            pass
+
+        class SysCallError(object):
+            pass
+
 class GreenSSL(GreenSocket):
     """ Nonblocking wrapper for SSL.Connection objects.
     
     """
     def __init__(self, fd):
         super(GreenSSL, self).__init__(fd)
-        assert(isinstance(fd, (util.SSL.ConnectionType)),
+        assert(isinstance(fd, (SSL.ConnectionType)),
                "GreenSSL can only be constructed with an "\
                "OpenSSL Connection object")
         self.sock = self
         while True:
             try:
                 return self.fd.do_handshake()
-            except util.SSL.WantReadError:
+            except SSL.WantReadError:
                 trampoline(self.fd.fileno(), 
                            read=True, 
                            timeout=self.timeout, 
                            timeout_exc=socket.timeout)
-            except util.SSL.WantWriteError:
+            except SSL.WantWriteError:
                 trampoline(self.fd.fileno(), 
                            write=True, 
                            timeout=self.timeout, 
         while True:
             try:
                 return self.fd.read(size)
-            except util.SSL.WantReadError:
+            except SSL.WantReadError:
                 trampoline(self.fd.fileno(), 
                            read=True, 
                            timeout=self.timeout, 
                            timeout_exc=socket.timeout)
-            except util.SSL.WantWriteError:
+            except SSL.WantWriteError:
                 trampoline(self.fd.fileno(), 
                            write=True, 
                            timeout=self.timeout, 
                            timeout_exc=socket.timeout)
-            except util.SSL.SysCallError, e:
-                if e[0] == -1:
+            except SSL.ZeroReturnError:
+                return ''
+            except SSL.SysCallError, e:
+                if e[0] == -1 or e[0] > 0:
                     return ''
             
     recv = read
         while True:
             try:
                 return self.fd.write(data)
-            except util.SSL.WantReadError:
+            except SSL.WantReadError:
                 trampoline(self.fd.fileno(), 
                            read=True, 
                            timeout=self.timeout, 
                            timeout_exc=socket.timeout)
-            except util.SSL.WantWriteError:
+            except SSL.WantWriteError:
                 trampoline(self.fd.fileno(), 
                            write=True, 
                            timeout=self.timeout, 
         while True:
             try:
                 return self.fd.shutdown()
-            except util.SSL.WantReadError:
+            except SSL.WantReadError:
                 trampoline(self.fd.fileno(), 
                            read=True, 
                            timeout=self.timeout, 
                            timeout_exc=socket.timeout)
-            except util.SSL.WantWriteError:
+            except SSL.WantWriteError:
                 trampoline(self.fd.fileno(), 
                            write=True, 
                            timeout=self.timeout, 
 import socket
 import errno
 
-try:
-    from OpenSSL import SSL
-except ImportError:
-    class SSL(object):
-        class WantWriteError(object):
-            pass
-
-        class WantReadError(object):
-            pass
-
-        class ZeroReturnError(object):
-            pass
-
-        class SysCallError(object):
-            pass
-
-
 def g_log(*args):
     import sys
     from eventlet.support import greenlets as greenlet
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.