Minor var naming changes

This commit is contained in:
Strahinja Val Markovic 2014-03-07 11:28:53 -08:00
parent 9e54390cda
commit 7a4f5a4a53
2 changed files with 14 additions and 14 deletions

View File

@ -27,10 +27,10 @@ from ycm.unsafe_thread_pool_executor import UnsafeThreadPoolExecutor
from ycm import vimsupport from ycm import vimsupport
from ycm.server.responses import ServerError, UnknownExtraConf from ycm.server.responses import ServerError, UnknownExtraConf
HEADERS = {'content-type': 'application/json'} _HEADERS = {'content-type': 'application/json'}
EXECUTOR = UnsafeThreadPoolExecutor( max_workers = 30 ) _EXECUTOR = UnsafeThreadPoolExecutor( max_workers = 30 )
# Setting this to None seems to screw up the Requests/urllib3 libs. # Setting this to None seems to screw up the Requests/urllib3 libs.
DEFAULT_TIMEOUT_SEC = 30 _DEFAULT_TIMEOUT_SEC = 30
class BaseRequest( object ): class BaseRequest( object ):
def __init__( self ): def __init__( self ):
@ -52,7 +52,7 @@ class BaseRequest( object ):
# |timeout| is num seconds to tolerate no response from server before giving # |timeout| is num seconds to tolerate no response from server before giving
# up; see Requests docs for details (we just pass the param along). # up; see Requests docs for details (we just pass the param along).
@staticmethod @staticmethod
def GetDataFromHandler( handler, timeout = DEFAULT_TIMEOUT_SEC ): def GetDataFromHandler( handler, timeout = _DEFAULT_TIMEOUT_SEC ):
return JsonFromFuture( BaseRequest._TalkToHandlerAsync( '', return JsonFromFuture( BaseRequest._TalkToHandlerAsync( '',
handler, handler,
'GET', 'GET',
@ -63,7 +63,7 @@ class BaseRequest( object ):
# |timeout| is num seconds to tolerate no response from server before giving # |timeout| is num seconds to tolerate no response from server before giving
# up; see Requests docs for details (we just pass the param along). # up; see Requests docs for details (we just pass the param along).
@staticmethod @staticmethod
def PostDataToHandler( data, handler, timeout = DEFAULT_TIMEOUT_SEC ): def PostDataToHandler( data, handler, timeout = _DEFAULT_TIMEOUT_SEC ):
return JsonFromFuture( BaseRequest.PostDataToHandlerAsync( data, return JsonFromFuture( BaseRequest.PostDataToHandlerAsync( data,
handler, handler,
timeout ) ) timeout ) )
@ -73,7 +73,7 @@ class BaseRequest( object ):
# |timeout| is num seconds to tolerate no response from server before giving # |timeout| is num seconds to tolerate no response from server before giving
# up; see Requests docs for details (we just pass the param along). # up; see Requests docs for details (we just pass the param along).
@staticmethod @staticmethod
def PostDataToHandlerAsync( data, handler, timeout = DEFAULT_TIMEOUT_SEC ): def PostDataToHandlerAsync( data, handler, timeout = _DEFAULT_TIMEOUT_SEC ):
return BaseRequest._TalkToHandlerAsync( data, handler, 'POST', timeout ) return BaseRequest._TalkToHandlerAsync( data, handler, 'POST', timeout )
@ -85,16 +85,16 @@ class BaseRequest( object ):
def _TalkToHandlerAsync( data, def _TalkToHandlerAsync( data,
handler, handler,
method, method,
timeout = DEFAULT_TIMEOUT_SEC ): timeout = _DEFAULT_TIMEOUT_SEC ):
def SendRequest( data, handler, method, timeout ): def SendRequest( data, handler, method, timeout ):
if method == 'POST': if method == 'POST':
return BaseRequest.session.post( _BuildUri( handler ), return BaseRequest.session.post( _BuildUri( handler ),
data = json.dumps( data ), data = json.dumps( data ),
headers = HEADERS, headers = _HEADERS,
timeout = timeout ) timeout = timeout )
if method == 'GET': if method == 'GET':
return BaseRequest.session.get( _BuildUri( handler ), return BaseRequest.session.get( _BuildUri( handler ),
headers = HEADERS, headers = _HEADERS,
timeout = timeout ) timeout = timeout )
@retries( 5, delay = 0.5, backoff = 1.5 ) @retries( 5, delay = 0.5, backoff = 1.5 )
@ -102,18 +102,18 @@ class BaseRequest( object ):
if method == 'POST': if method == 'POST':
return requests.post( _BuildUri( handler ), return requests.post( _BuildUri( handler ),
data = json.dumps( data ), data = json.dumps( data ),
headers = HEADERS ) headers = _HEADERS )
if method == 'GET': if method == 'GET':
return requests.get( _BuildUri( handler ), return requests.get( _BuildUri( handler ),
headers = HEADERS ) headers = _HEADERS )
if not _CheckServerIsHealthyWithCache(): if not _CheckServerIsHealthyWithCache():
return EXECUTOR.submit( DelayedSendRequest, data, handler, method ) return _EXECUTOR.submit( DelayedSendRequest, data, handler, method )
return SendRequest( data, handler, method, timeout ) return SendRequest( data, handler, method, timeout )
session = FuturesSession( executor = EXECUTOR ) session = FuturesSession( executor = _EXECUTOR )
server_location = 'http://localhost:6666' server_location = 'http://localhost:6666'

View File

@ -115,7 +115,6 @@ class YouCompleteMe( object ):
args.append('--keep_logfiles') args.append('--keep_logfiles')
self._server_popen = utils.SafePopen( args, stdout = PIPE, stderr = PIPE) self._server_popen = utils.SafePopen( args, stdout = PIPE, stderr = PIPE)
BaseRequest.server_location = 'http://localhost:' + str( server_port ) BaseRequest.server_location = 'http://localhost:' + str( server_port )
self._NotifyUserIfServerCrashed() self._NotifyUserIfServerCrashed()
@ -151,6 +150,7 @@ class YouCompleteMe( object ):
self._server_popen.terminate() self._server_popen.terminate()
utils.RemoveIfExists( self._temp_options_filename ) utils.RemoveIfExists( self._temp_options_filename )
def RestartServer( self ): def RestartServer( self ):
vimsupport.PostVimMessage( 'Restarting ycmd server...' ) vimsupport.PostVimMessage( 'Restarting ycmd server...' )
self._user_notified_about_crash = False self._user_notified_about_crash = False