@@ -116,18 +116,20 @@ def get_my_user_header(self):
116116 'last_seen' : int (time ()),
117117 }
118118
119- async def create_connection (self , host , port ):
119+ async def create_connection (self , host , port ) -> bool :
120+ """create connection without exception"""
120121 if self .f_stop :
121122 return False
122123 # get connection list
123124 future : asyncio .Future = loop .run_in_executor (
124125 None , socket .getaddrinfo , host , port , socket .AF_UNSPEC , socket .SOCK_STREAM )
125126 try :
126127 await asyncio .wait_for (future , 10.0 )
127- except socket .gaierror :
128+ address_infos = future .result ()
129+ except (asyncio .TimeoutError , socket .gaierror ):
128130 return False
129131 # try to connect one by one
130- for af , socktype , proto , canonname , host_port in future . result () :
132+ for af , socktype , proto , canonname , host_port in address_infos :
131133 if host_port [0 ] in ban_address :
132134 return False # baned address
133135 try :
@@ -510,7 +512,7 @@ async def check_reachable(self, new_user: User):
510512 result = future .result ()
511513 if result != 0 :
512514 f_tcp = False
513- except OSError :
515+ except ( OSError , asyncio . TimeoutError ) :
514516 f_tcp = False
515517 loop .run_in_executor (None , sock .close )
516518 # try to check UDP
0 commit comments