<s> import asyncio <EOL> import socket <EOL> def future_hostname ( future_gethostbyaddr , fallback_ip ) : <EOL> if future_gethostbyaddr . done ( ) : <EOL> try : <EOL> val = future_gethostbyaddr . result ( ) [ <NUM_LIT:0> ] <EOL> except socket . herror as err : <EOL> if err . errno == <NUM_LIT:1> : <EOL> val = fallback_ip <EOL> else : <EOL> raise <EOL> return _wrap_future_result ( future_gethostbyaddr , val ) <EOL> return future_gethostbyaddr <EOL> def future_reverse_ip ( future_gethostbyaddr , fallback_ip ) : <EOL> if future_gethostbyaddr . done ( ) : <EOL> try : <EOL> val = future_gethostbyaddr . result ( ) [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] <EOL> except socket . herror as err : <EOL> if err . errno == <NUM_LIT:1> : <EOL> val = fallback_ip <EOL> else : <EOL> raise <EOL> return _wrap_future_result ( future_gethostbyaddr , val ) <EOL> return future_gethostbyaddr <EOL> def future_fqdn ( future_gethostbyaddr , fallback_ip ) : <EOL> if future_gethostbyaddr . done ( ) : <EOL> try : <EOL> val = future_gethostbyaddr . result ( ) [ <NUM_LIT:0> ] <EOL> except socket . herror as err : <EOL> if err . errno == <NUM_LIT:1> : <EOL> val = fallback_ip <EOL> else : <EOL> raise <EOL> return _wrap_future_result ( future_gethostbyaddr , val ) <EOL> return future_gethostbyaddr <EOL> def _wrap_future_result ( future , result ) : <EOL> """<STR_LIT>""" <EOL> future = asyncio . Future ( ) <EOL> future . set_result ( result ) <EOL> return future </s>
