<s> import errno <EOL> import socket <EOL> from riak . transports . pool import Pool <EOL> from riak . transports . tcp . transport import TcpTransport <EOL> class TcpPool ( Pool ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , client , ** options ) : <EOL> super ( TcpPool , self ) . __init__ ( ) <EOL> self . _client = client <EOL> self . _options = options <EOL> def create_resource ( self ) : <EOL> node = self . _client . _choose_node ( ) <EOL> return TcpTransport ( node = node , <EOL> client = self . _client , <EOL> ** self . _options ) <EOL> def destroy_resource ( self , tcp ) : <EOL> tcp . close ( ) <EOL> CONN_CLOSED_ERRORS = ( <EOL> errno . EHOSTUNREACH , <EOL> errno . ECONNRESET , <EOL> errno . ECONNREFUSED , <EOL> errno . ECONNABORTED , <EOL> errno . ETIMEDOUT , <EOL> errno . EBADF , <EOL> errno . EPIPE <EOL> ) <EOL> def is_retryable ( err ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( err , socket . error ) : <EOL> code = err . args [ <NUM_LIT:0> ] <EOL> return code in CONN_CLOSED_ERRORS <EOL> else : <EOL> return False </s>
