def connect_ensime_server(self):
        """Start initial connection with the server."""
        self.log.debug('connect_ensime_server: in')
        server_v2 = isinstance(self, EnsimeClientV2)

        def disable_completely(e):
            if e:
                self.log.error('connection error: %s', e, exc_info=True)
            self.shutdown_server()
            self._display_ws_warning()

        if self.running and self.number_try_connection:
            self.number_try_connection -= 1
            if not self.ensime_server:
                port = self.ensime.http_port()
                uri = "websocket" if server_v2 else "jerky"
                self.ensime_server = gconfig["ensime_server"].format(port, uri)
            with catch(websocket.WebSocketException, disable_completely):
                # Use the default timeout (no timeout).
                options = {"subprotocols": ["jerky"]} if server_v2 else {}
                options['enable_multithread'] = True
                self.log.debug("About to connect to %s with options %s",
                               self.ensime_server, options)
                self.ws = websocket.create_connection(self.ensime_server, **options)
            if self.ws:
                self.send_request({"typehint": "ConnectionInfoReq"})
        else:
            # If it hits this, number_try_connection is 0
            disable_completely(None)
def connect_ensime_server ( self ) : self . log . debug ( 'connect_ensime_server: in' ) server_v2 = isinstance ( self , EnsimeClientV2 ) def disable_completely ( e ) : if e : self . log . error ( 'connection error: %s' , e , exc_info = True ) self . shutdown_server ( ) self . _display_ws_warning ( ) if self . running and self . number_try_connection : self . number_try_connection -= 1 if not self . ensime_server : port = self . ensime . http_port ( ) uri = "websocket" if server_v2 else "jerky" self . ensime_server = gconfig [ "ensime_server" ] . format ( port , uri ) with catch ( websocket . WebSocketException , disable_completely ) : options = { "subprotocols" : [ "jerky" ] } if server_v2 else { } options [ 'enable_multithread' ] = True self . log . debug ( "About to connect to %s with options %s" , self . ensime_server , options ) self . ws = websocket . create_connection ( self . ensime_server , ** options ) if self . ws : self . send_request ( { "typehint" : "ConnectionInfoReq" } ) else : disable_completely ( None )
Start initial connection with the server.