<s> import os <EOL> import sys <EOL> __import__ ( '<STR_LIT>' ) <EOL> __socket = sys . modules [ '<STR_LIT>' ] <EOL> __all__ = __socket . __all__ <EOL> __patched__ = __socket . __patched__ + [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ] <EOL> from eventlet . patcher import slurp_properties <EOL> slurp_properties ( __socket , globals ( ) , srckeys = dir ( __socket ) ) <EOL> greendns = None <EOL> if os . environ . get ( "<STR_LIT>" , '<STR_LIT>' ) . lower ( ) != "<STR_LIT:yes>" : <EOL> try : <EOL> from eventlet . support import greendns <EOL> except ImportError as ex : <EOL> pass <EOL> if greendns : <EOL> gethostbyname = greendns . gethostbyname <EOL> getaddrinfo = greendns . getaddrinfo <EOL> gethostbyname_ex = greendns . gethostbyname_ex <EOL> getnameinfo = greendns . getnameinfo <EOL> __patched__ = __patched__ + [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def create_connection ( address , <EOL> timeout = _GLOBAL_DEFAULT_TIMEOUT , <EOL> source_address = None ) : <EOL> """<STR_LIT>""" <EOL> err = "<STR_LIT>" <EOL> host , port = address <EOL> for res in getaddrinfo ( host , port , <NUM_LIT:0> , SOCK_STREAM ) : <EOL> af , socktype , proto , canonname , sa = res <EOL> sock = None <EOL> try : <EOL> sock = socket ( af , socktype , proto ) <EOL> if timeout is not _GLOBAL_DEFAULT_TIMEOUT : <EOL> sock . settimeout ( timeout ) <EOL> if source_address : <EOL> sock . bind ( source_address ) <EOL> sock . connect ( sa ) <EOL> return sock <EOL> except error as e : <EOL> err = e <EOL> if sock is not None : <EOL> sock . close ( ) <EOL> if not isinstance ( err , error ) : <EOL> err = error ( err ) <EOL> raise err </s>
