From 40464f6e0da4825817e85a021ce9618b00043c64 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Thu, 17 Oct 2013 14:21:37 -0700 Subject: [PATCH] Resolving issues with event requests timing out It appears that the issue comes from sending a None timeout to Requests. It seems it's a bug in Requests/urllib3. So we just pick an arbitrary long timeout of 30s as the default. --- python/ycm/client/base_request.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/ycm/client/base_request.py b/python/ycm/client/base_request.py index 45ce8926..78ac368d 100644 --- a/python/ycm/client/base_request.py +++ b/python/ycm/client/base_request.py @@ -29,6 +29,8 @@ from ycm.server.responses import ServerError, UnknownExtraConf HEADERS = {'content-type': 'application/json'} EXECUTOR = ThreadPoolExecutor( max_workers = 10 ) +# Setting this to None seems to screw up the Requests/urllib3 libs. +DEFAULT_TIMEOUT_SEC = 30 class BaseRequest( object ): def __init__( self ): @@ -51,7 +53,7 @@ class BaseRequest( object ): # |timeout| is num seconds to tolerate no response from server before giving # up; see Requests docs for details (we just pass the param along). @staticmethod - def PostDataToHandler( data, handler, timeout = None ): + def PostDataToHandler( data, handler, timeout = DEFAULT_TIMEOUT_SEC ): return JsonFromFuture( BaseRequest.PostDataToHandlerAsync( data, handler, timeout ) ) @@ -61,7 +63,7 @@ class BaseRequest( object ): # |timeout| is num seconds to tolerate no response from server before giving # up; see Requests docs for details (we just pass the param along). @staticmethod - def PostDataToHandlerAsync( data, handler, timeout = None ): + def PostDataToHandlerAsync( data, handler, timeout = DEFAULT_TIMEOUT_SEC ): def PostData( data, handler, timeout ): return BaseRequest.session.post( _BuildUri( handler ), data = json.dumps( data ),