##// END OF EJS Templates
caches: make gevent curl connection cache friendly....
marcink -
r2946:193b4eb7 default
parent child Browse files
Show More
@@ -176,7 +176,6 b' class BaseRepository(object):'
176 176 EMPTY_COMMIT_ID = '0' * 40
177 177
178 178 path = None
179 _remote = None
180 179
181 180 def __init__(self, repo_path, config=None, create=False, **kwargs):
182 181 """
@@ -222,6 +221,10 b' class BaseRepository(object):'
222 221 return config
223 222
224 223 @LazyProperty
224 def _remote(self):
225 raise NotImplementedError
226
227 @LazyProperty
225 228 def EMPTY_COMMIT(self):
226 229 return EmptyCommit(self.EMPTY_COMMIT_ID)
227 230
@@ -62,8 +62,7 b' class GitRepository(BaseRepository):'
62 62
63 63 self.path = safe_str(os.path.abspath(repo_path))
64 64 self.config = config if config else self.get_default_config()
65 self._remote = connection.Git(
66 self.path, self.config, with_wire=with_wire)
65 self.with_wire = with_wire
67 66
68 67 self._init_repo(create, src_url, update_after_clone, bare)
69 68
@@ -71,6 +70,10 b' class GitRepository(BaseRepository):'
71 70 self._commit_ids = {}
72 71
73 72 @LazyProperty
73 def _remote(self):
74 return connection.Git(self.path, self.config, with_wire=self.with_wire)
75
76 @LazyProperty
74 77 def bare(self):
75 78 return self._remote.bare()
76 79
@@ -77,9 +77,7 b' class MercurialRepository(BaseRepository'
77 77 # special requirements
78 78 self.config = config if config else self.get_default_config(
79 79 default=[('extensions', 'largefiles', '1')])
80
81 self._remote = connection.Hg(
82 self.path, self.config, with_wire=with_wire)
80 self.with_wire = with_wire
83 81
84 82 self._init_repo(create, src_url, update_after_clone)
85 83
@@ -87,6 +85,10 b' class MercurialRepository(BaseRepository'
87 85 self._commit_ids = {}
88 86
89 87 @LazyProperty
88 def _remote(self):
89 return connection.Hg(self.path, self.config, with_wire=self.with_wire)
90
91 @LazyProperty
90 92 def commit_ids(self):
91 93 """
92 94 Returns list of commit ids, in ascending order. Being lazy
@@ -72,11 +72,13 b' class SubversionRepository(base.BaseRepo'
72 72 **kwargs):
73 73 self.path = safe_str(os.path.abspath(repo_path))
74 74 self.config = config if config else self.get_default_config()
75 self._remote = connection.Svn(
76 self.path, self.config)
77 75
78 76 self._init_repo(create, src_url)
79 77
78 @LazyProperty
79 def _remote(self):
80 return connection.Svn(self.path, self.config)
81
80 82 def _init_repo(self, create, src_url):
81 83 if create and os.path.exists(self.path):
82 84 raise RepositoryError(
@@ -27,6 +27,7 b' class in a way that is compatible with g'
27 27 import logging
28 28 import gevent
29 29 import pycurl
30 import greenlet
30 31
31 32 # Import everything from pycurl.
32 33 # This allows us to use this module as a drop in replacement of pycurl.
@@ -230,6 +231,12 b' class GeventCurl(object):'
230 231 This perform method is compatible with gevent because it uses gevent
231 232 synchronization mechanisms to wait for the request to finish.
232 233 """
234 if getattr(self._curl, 'waiter', None) is not None:
235 current = greenlet.getcurrent()
236 msg = 'This curl object is already used by another greenlet, {}, \n' \
237 'this is {}'.format(self._curl.waiter, current)
238 raise Exception(msg)
239
233 240 waiter = self._curl.waiter = Waiter()
234 241 try:
235 242 self._multi.add_handle(self._curl)
@@ -2339,8 +2339,11 b' class Repository(Base, BaseModel):'
2339 2339 def get_instance_cached(repo_id):
2340 2340 return self._get_instance()
2341 2341
2342 # we must use thread scoped cache here,
2343 # because each thread of gevent needs it's own connection and cache
2342 2344 inv_context_manager = rc_cache.InvalidationContext(
2343 uid=cache_namespace_uid, invalidation_namespace=invalidation_namespace)
2345 uid=cache_namespace_uid, invalidation_namespace=invalidation_namespace,
2346 thread_scoped=True)
2344 2347 with inv_context_manager as invalidation_context:
2345 2348 args = (self.repo_id,)
2346 2349 # re-compute and store cache if we get invalidate signal
General Comments 0
You need to be logged in to leave comments. Login now