Show More
@@ -29,7 +29,7 b' from rhodecode.lib.vcs.exceptions import' | |||||
29 | from rhodecode.lib.vcs.exceptions import TagAlreadyExistError |
|
29 | from rhodecode.lib.vcs.exceptions import TagAlreadyExistError | |
30 | from rhodecode.lib.vcs.exceptions import TagDoesNotExistError |
|
30 | from rhodecode.lib.vcs.exceptions import TagDoesNotExistError | |
31 | from rhodecode.lib.vcs.utils import safe_unicode, makedate, date_fromtimestamp |
|
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 | from rhodecode.lib.vcs.utils.ordered_dict import OrderedDict |
|
33 | from rhodecode.lib.vcs.utils.ordered_dict import OrderedDict | |
34 | from rhodecode.lib.vcs.utils.paths import abspath |
|
34 | from rhodecode.lib.vcs.utils.paths import abspath | |
35 | from rhodecode.lib.vcs.utils.paths import get_user_home |
|
35 | from rhodecode.lib.vcs.utils.paths import get_user_home | |
@@ -63,7 +63,7 b' class GitRepository(BaseRepository):' | |||||
63 | abspath(get_user_home(), '.gitconfig'), |
|
63 | abspath(get_user_home(), '.gitconfig'), | |
64 | ] |
|
64 | ] | |
65 |
|
65 | |||
66 | @LazyProperty |
|
66 | @ThreadLocalLazyProperty | |
67 | def _repo(self): |
|
67 | def _repo(self): | |
68 | repo = Repo(self.path) |
|
68 | repo = Repo(self.path) | |
69 | #temporary set that to now at later we will move it to constructor |
|
69 | #temporary set that to now at later we will move it to constructor |
@@ -26,3 +26,21 b' class LazyProperty(object):' | |||||
26 | return self |
|
26 | return self | |
27 | result = obj.__dict__[self.__name__] = self._func(obj) |
|
27 | result = obj.__dict__[self.__name__] = self._func(obj) | |
28 | return result |
|
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