##// END OF EJS Templates
cache-key: make cleanup safe so we don't cause any errors on exit in case it fails..
ergo -
r3893:c865048b default
parent child Browse files
Show More
@@ -1,35 +1,40 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2015-2019 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 import atexit
22 22 import logging
23 23
24 24 log = logging.getLogger(__name__)
25 25
26 26 cache_keys_by_pid = []
27 27
28 28
29 29 @atexit.register
30 30 def free_cache_keys():
31 31 from rhodecode.model.db import Session, CacheKey
32 32 log.info('Clearing %s cache keys', len(cache_keys_by_pid))
33 for cache_key in cache_keys_by_pid:
34 CacheKey.query().filter(CacheKey.cache_key == cache_key).delete()
35 Session().commit()
33
34 if cache_keys_by_pid:
35 try:
36 for cache_key in cache_keys_by_pid:
37 CacheKey.query().filter(CacheKey.cache_key == cache_key).delete()
38 Session().commit()
39 except Exception:
40 log.warn('Failed to clear keys, exiting gracefully')
General Comments 0
You need to be logged in to leave comments. Login now