#NEWLINE# def websocket_open( io_loop , url , origin = None , host = None ) : #NEWLINE# #INDENT# result = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# def handle_connection( future ) : #NEWLINE# #INDENT# result [ 'connection' ] = future #NEWLINE# io_loop . stop ( ) #NEWLINE# #UNINDENT# request = HTTPRequest ( url ) #NEWLINE# if ( origin is not None ) : #NEWLINE# #INDENT# request . headers [ 'Origin' ] = origin #NEWLINE# #UNINDENT# if ( host is not None ) : #NEWLINE# #INDENT# request . headers [ 'Host' ] = host #NEWLINE# #UNINDENT# websocket_connect ( request , callback = handle_connection , io_loop = io_loop ) #NEWLINE# io_loop . start ( ) #NEWLINE# if ( 'connection' not in result ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Failed to handle websocket connect' ) #NEWLINE# #UNINDENT# future = result [ 'connection' ] #NEWLINE# if future . exception ( ) : #NEWLINE# #INDENT# raise future . exception ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# future . result ( ) . close ( ) #NEWLINE# return None