##// END OF EJS Templates
http_client: some reformatting
super-admin -
r4790:eadea78d default
parent child Browse files
Show More
@@ -41,6 +41,7 b' from rhodecode.lib import rc_cache'
41 from rhodecode.lib.rc_cache.utils import compute_key_from_params
41 from rhodecode.lib.rc_cache.utils import compute_key_from_params
42 from rhodecode.lib.system_info import get_cert_path
42 from rhodecode.lib.system_info import get_cert_path
43 from rhodecode.lib.vcs import exceptions, CurlSession
43 from rhodecode.lib.vcs import exceptions, CurlSession
44 from rhodecode.lib.utils2 import str2bool
44
45
45 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
46
47
@@ -242,20 +243,16 b' class RemoteRepo(object):'
242 context_uid = wire.get('context')
243 context_uid = wire.get('context')
243 return context_uid, payload
244 return context_uid, payload
244
245
245 @exceptions.map_vcs_exceptions
246 def get_local_cache(self, name, args):
246 def _call(self, name, *args, **kwargs):
247 context_uid, payload = self._base_call(name, *args, **kwargs)
248 url = self.url
249
250 start = time.time()
251
252 cache_on = False
247 cache_on = False
253 cache_key = ''
248 cache_key = ''
254 local_cache_on = rhodecode.CONFIG.get('vcs.methods.cache')
249 local_cache_on = str2bool(rhodecode.CONFIG.get('vcs.methods.cache'))
255
250
256 cache_methods = [
251 cache_methods = [
257 'branches', 'tags', 'bookmarks',
252 'branches', 'tags', 'bookmarks',
258 'is_large_file', 'is_binary', 'fctx_size', 'node_history', 'blob_raw_length',
253 'is_large_file', 'is_binary',
254 'fctx_size', 'stream:fctx_node_data', 'blob_raw_length',
255 'node_history',
259 'revision', 'tree_items',
256 'revision', 'tree_items',
260 'ctx_list',
257 'ctx_list',
261 'bulk_request',
258 'bulk_request',
@@ -267,6 +264,16 b' class RemoteRepo(object):'
267 call_args = [a for a in args]
264 call_args = [a for a in args]
268 cache_key = compute_key_from_params(repo_state_uid, name, *call_args)
265 cache_key = compute_key_from_params(repo_state_uid, name, *call_args)
269
266
267 return cache_on, cache_key
268
269 @exceptions.map_vcs_exceptions
270 def _call(self, name, *args, **kwargs):
271 context_uid, payload = self._base_call(name, *args, **kwargs)
272 url = self.url
273
274 start = time.time()
275 cache_on, cache_key = self.get_local_cache(name, args)
276
270 @self._cache_region.conditional_cache_on_arguments(
277 @self._cache_region.conditional_cache_on_arguments(
271 namespace=self._cache_namespace, condition=cache_on and cache_key)
278 namespace=self._cache_namespace, condition=cache_on and cache_key)
272 def remote_call(_cache_key):
279 def remote_call(_cache_key):
@@ -288,13 +295,16 b' class RemoteRepo(object):'
288 url = self.stream_url
295 url = self.stream_url
289
296
290 start = time.time()
297 start = time.time()
291 if self._call_with_logging:
298 cache_on, cache_key = self.get_local_cache(name, args)
292 log.debug('Calling %s@%s with args:%.10240r. wire_context: %s',
293 url, name, args, context_uid)
294
299
295 result = _streaming_remote_call(url, payload, EXCEPTIONS_MAP, self._session,
300 # Cache is a problem because this is a stream
296 self.CHUNK_SIZE)
301 def streaming_remote_call(_cache_key):
302 if self._call_with_logging:
303 log.debug('Calling %s@%s with args:%.10240r. wire_context: %s cache_on: %s',
304 url, name, args, context_uid, cache_on)
305 return _streaming_remote_call(url, payload, EXCEPTIONS_MAP, self._session, self.CHUNK_SIZE)
297
306
307 result = streaming_remote_call(cache_key)
298 if self._call_with_logging:
308 if self._call_with_logging:
299 log.debug('Call %s@%s took: %.4fs. wire_context: %s',
309 log.debug('Call %s@%s took: %.4fs. wire_context: %s',
300 url, name, time.time()-start, context_uid)
310 url, name, time.time()-start, context_uid)
General Comments 0
You need to be logged in to leave comments. Login now