Catch ReadTimeout exception on requests

This commit is contained in:
micbou 2016-03-05 22:13:32 +01:00
parent d4f8c1d404
commit f6d5f68d6b
4 changed files with 14 additions and 5 deletions

View File

@ -23,11 +23,12 @@ from future import standard_library
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
@ -56,7 +57,7 @@ class CommandRequest( BaseRequest ):
try:
self._response = self.PostDataToHandler( request_data,
'run_completer_command' )
except ServerError as e:
except ( ServerError, ReadTimeout ) as e:
HandleServerException( e )

View File

@ -23,6 +23,8 @@ from future import standard_library
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
@ -40,7 +42,7 @@ class CompleterAvailableRequest( BaseRequest ):
try:
self._response = self.PostDataToHandler( request_data,
'semantic_completion_available' )
except ServerError as e:
except ( ServerError, ReadTimeout ) as e:
HandleServerException( e )

View File

@ -23,6 +23,8 @@ from future import standard_library
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,
@ -59,7 +61,7 @@ class CompletionRequest( BaseRequest ):
HandleServerException( MakeServerException( e ) )
return JsonFromFuture( self._response_future )[ 'completions' ]
except ServerError as e:
except ( ServerError, ReadTimeout ) as e:
HandleServerException( e )
return []

View File

@ -23,6 +23,8 @@ from future import standard_library
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,
@ -66,7 +68,7 @@ class EventNotification( BaseRequest ):
_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 []
@ -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' )