Skip to content

Commit

Permalink
Catch ReadTimeout exception on requests
Browse files Browse the repository at this point in the history
  • Loading branch information
micbou committed Mar 5, 2016
1 parent d4f8c1d commit f6d5f68
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions python/ycm/client/command_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
standard_library.install_aliases()
from builtins import * # noqa

from requests.exceptions import ReadTimeout
import vim

from ycmd.responses import ServerError
from ycm.client.base_request import ( BaseRequest, BuildRequestData,
HandleServerException )

from ycm import vimsupport
from ycmd.utils import ToUnicode

Expand Down Expand Up @@ -56,7 +57,7 @@ def Start( self ):
try:
self._response = self.PostDataToHandler( request_data,
'run_completer_command' )
except ServerError as e:
except ( ServerError, ReadTimeout ) as e:
HandleServerException( e )


Expand Down
4 changes: 3 additions & 1 deletion python/ycm/client/completer_available_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
standard_library.install_aliases()
from builtins import * # noqa

from requests.exceptions import ReadTimeout

from ycm.client.base_request import ( BaseRequest, BuildRequestData,
HandleServerException )
from ycmd.responses import ServerError
Expand All @@ -40,7 +42,7 @@ def Start( self ):
try:
self._response = self.PostDataToHandler( request_data,
'semantic_completion_available' )
except ServerError as e:
except ( ServerError, ReadTimeout ) as e:
HandleServerException( e )


Expand Down
4 changes: 3 additions & 1 deletion python/ycm/client/completion_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
standard_library.install_aliases()
from builtins import * # noqa

from requests.exceptions import ReadTimeout

from ycmd.utils import ToUnicode
from ycm.client.base_request import ( BaseRequest, JsonFromFuture,
HandleServerException,
Expand Down Expand Up @@ -59,7 +61,7 @@ def RawResponse( self ):
HandleServerException( MakeServerException( e ) )

return JsonFromFuture( self._response_future )[ 'completions' ]
except ServerError as e:
except ( ServerError, ReadTimeout ) as e:
HandleServerException( e )
return []

Expand Down
6 changes: 5 additions & 1 deletion python/ycm/client/event_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
standard_library.install_aliases()
from builtins import * # noqa

from requests.exceptions import ReadTimeout

from ycm import vimsupport
from ycmd.responses import UnknownExtraConf, ServerError
from ycm.client.base_request import ( BaseRequest, BuildRequestData,
Expand Down Expand Up @@ -66,7 +68,7 @@ def Response( self ):
_LoadExtraConfFile( e.extra_conf_file )
else:
_IgnoreExtraConfFile( e.extra_conf_file )
except ServerError as e:
except ( ServerError, ReadTimeout ) as e:
HandleServerException( e )

return self._cached_response if self._cached_response else []
Expand All @@ -76,10 +78,12 @@ def SendEventNotificationAsync( event_name, extra_data = None ):
event = EventNotification( event_name, extra_data )
event.Start()


def _LoadExtraConfFile( filepath ):
BaseRequest.PostDataToHandler( { 'filepath': filepath },
'load_extra_conf_file' )


def _IgnoreExtraConfFile( filepath ):
BaseRequest.PostDataToHandler( { 'filepath': filepath },
'ignore_extra_conf_file' )

0 comments on commit f6d5f68

Please sign in to comment.