File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import errno
12import socket
23import struct
34
910from riak .security import SecurityError , USE_STDLIB_SSL
1011from riak .transports .pool import BadResource
1112
12- if not USE_STDLIB_SSL :
13- from OpenSSL .SSL import Connection
14- from riak .transports .security import configure_pyopenssl_context
15- else :
13+ if USE_STDLIB_SSL :
1614 import ssl
1715 from riak .transports .security import configure_ssl_context
16+ else :
17+ from OpenSSL .SSL import Connection
18+ from riak .transports .security import configure_pyopenssl_context
1819
1920
2021class TcpConnection (object ):
@@ -208,7 +209,16 @@ def close(self):
208209 Closes the underlying socket of the PB connection.
209210 """
210211 if self ._socket :
211- self ._socket .shutdown (socket .SHUT_RDWR )
212+ if USE_STDLIB_SSL :
213+ # NB: Python 2.7.8 and earlier does not have a compatible
214+ # shutdown() method due to the SSL lib
215+ try :
216+ self ._socket .shutdown (socket .SHUT_RDWR )
217+ except IOError as e :
218+ # NB: sometimes this is the exception if the initial
219+ # connection didn't succeed correctly
220+ if e .errno != errno .EBADF :
221+ raise
212222 self ._socket .close ()
213223 del self ._socket
214224
You can’t perform that action at this time.
0 commit comments