##// END OF EJS Templates
cache exc store, and use glob.glob for scaning exc store
marcink -
r3975:6411e6b8 default
parent child Browse files
Show More
@@ -25,6 +25,7 b' import msgpack'
25 25 import logging
26 26 import traceback
27 27 import tempfile
28 import glob
28 29
29 30
30 31 log = logging.getLogger(__name__)
@@ -50,13 +51,20 b' def exc_serialize(exc_id, tb, exc_type):'
50 51 def exc_unserialize(tb):
51 52 return msgpack.unpackb(tb)
52 53
54 _exc_store = None
55
53 56
54 57 def get_exc_store():
55 58 """
56 59 Get and create exception store if it's not existing
57 60 """
61 global _exc_store
58 62 import rhodecode as app
59 63
64 if _exc_store is not None:
65 # quick global cache
66 return _exc_store
67
60 68 exc_store_dir = app.CONFIG.get('exception_tracker.store_path', '') or tempfile.gettempdir()
61 69 _exc_store_path = os.path.join(exc_store_dir, exc_store_dir_name)
62 70
@@ -64,6 +72,8 b' def get_exc_store():'
64 72 if not os.path.isdir(_exc_store_path):
65 73 os.makedirs(_exc_store_path)
66 74 log.debug('Initializing exceptions store at %s', _exc_store_path)
75 _exc_store = _exc_store_path
76
67 77 return _exc_store_path
68 78
69 79
@@ -119,16 +129,12 b' def _find_exc_file(exc_id, prefix=global'
119 129 # search without a prefix
120 130 exc_id = '{}'.format(exc_id)
121 131
122 # we need to search the store for such start pattern as above
123 for fname in os.listdir(exc_store_path):
124 if fname.startswith(exc_id):
125 exc_id = os.path.join(exc_store_path, fname)
126 break
127 continue
128 else:
129 exc_id = None
132 found_exc_id = None
133 matches = glob.glob(os.path.join(exc_store_path, exc_id) + '*')
134 if matches:
135 found_exc_id = matches[0]
130 136
131 return exc_id
137 return found_exc_id
132 138
133 139
134 140 def _read_exception(exc_id, prefix):
General Comments 0
You need to be logged in to leave comments. Login now