#NEWLINE# @ gen . coroutine #NEWLINE# def wait_for_server( ip , port , timeout = 10 ) : #NEWLINE# #INDENT# 'wait for any server to show up at ip:port' #NEWLINE# loop = ioloop . IOLoop . current ( ) #NEWLINE# tic = loop . time ( ) #NEWLINE# while ( ( loop . time ( ) - tic ) < timeout ) : #NEWLINE# #INDENT# if can_connect ( ip , port ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield gen . sleep ( 0.1 ) ) #NEWLINE# #UNINDENT# #UNINDENT# raise TimeoutError ( "Server at {ip}:{port} didn't respond in {timeout} seconds" . format ( ** locals ( ) ) )