@@ -113,10 +113,7 @@ def _connect(self, fam, typ):
113
113
114
114
async def async_getaddrinfo (host , port , fam = 0 , typ = 0 , proto = 0 , flags = 0 ):
115
115
loop = asyncio .get_running_loop ()
116
- try :
117
- result = await loop .getaddrinfo (host , port , family = fam , type = typ , proto = proto , flags = flags )
118
- except asyncio .exceptions .CancelledError :
119
- result = []
116
+ result = await loop .getaddrinfo (host , port , family = fam , type = typ , proto = proto , flags = flags )
120
117
return result
121
118
122
119
def run_async_in_thread (coro ):
@@ -132,8 +129,13 @@ def run_async_in_thread(coro):
132
129
def sync_getaddrinfo (* args ):
133
130
# Run in a separate thread to avoid deadlocks when users nest eventloops.
134
131
with concurrent .futures .ThreadPoolExecutor () as executor :
135
- future = executor .submit (run_async_in_thread , async_getaddrinfo (* args ))
136
- return future .result ()
132
+ try :
133
+ future = executor .submit (run_async_in_thread , async_getaddrinfo (* args ))
134
+ return future .result ()
135
+ except asyncio .exceptions .CancelledError :
136
+ return []
137
+ except socket .gaierror :
138
+ return []
137
139
138
140
with self .waitfor ('Opening connection to %s on port %s' % (self .rhost , self .rport )) as h :
139
141
hostnames = sync_getaddrinfo (self .rhost , self .rport , fam , typ , 0 , socket .AI_PASSIVE )
0 commit comments