Show More
@@ -29,7 +29,7 b' from rhodecode.lib.vcs.exceptions import' | |||
|
29 | 29 | from rhodecode.lib.vcs.exceptions import TagAlreadyExistError |
|
30 | 30 | from rhodecode.lib.vcs.exceptions import TagDoesNotExistError |
|
31 | 31 | from rhodecode.lib.vcs.utils import safe_unicode, makedate, date_fromtimestamp |
|
32 | from rhodecode.lib.vcs.utils.lazy import LazyProperty | |
|
32 | from rhodecode.lib.vcs.utils.lazy import LazyProperty, ThreadLocalLazyProperty | |
|
33 | 33 | from rhodecode.lib.vcs.utils.ordered_dict import OrderedDict |
|
34 | 34 | from rhodecode.lib.vcs.utils.paths import abspath |
|
35 | 35 | from rhodecode.lib.vcs.utils.paths import get_user_home |
@@ -63,7 +63,7 b' class GitRepository(BaseRepository):' | |||
|
63 | 63 | abspath(get_user_home(), '.gitconfig'), |
|
64 | 64 | ] |
|
65 | 65 | |
|
66 | @LazyProperty | |
|
66 | @ThreadLocalLazyProperty | |
|
67 | 67 | def _repo(self): |
|
68 | 68 | repo = Repo(self.path) |
|
69 | 69 | #temporary set that to now at later we will move it to constructor |
@@ -26,3 +26,21 b' class LazyProperty(object):' | |||
|
26 | 26 | return self |
|
27 | 27 | result = obj.__dict__[self.__name__] = self._func(obj) |
|
28 | 28 | return result |
|
29 | ||
|
30 | import threading | |
|
31 | ||
|
32 | ||
|
33 | class ThreadLocalLazyProperty(LazyProperty): | |
|
34 | """ | |
|
35 | Same as above but uses thread local dict for cache storage. | |
|
36 | """ | |
|
37 | ||
|
38 | def __get__(self, obj, klass=None): | |
|
39 | if obj is None: | |
|
40 | return self | |
|
41 | if not hasattr(obj, '__tl_dict__'): | |
|
42 | obj.__tl_dict__ = threading.local().__dict__ | |
|
43 | ||
|
44 | result = obj.__tl_dict__[self.__name__] = self._func(obj) | |
|
45 | return result | |
|
46 |
General Comments 0
You need to be logged in to leave comments.
Login now