We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b2bf697 commit 0d95a56Copy full SHA for 0d95a56
apps/common/util/rsa_util.py
@@ -40,15 +40,12 @@ def generate():
40
def get_key_pair():
41
rsa_value = rsa_cache.get(cache_key)
42
if rsa_value is None:
43
- lock.acquire()
44
- rsa_value = rsa_cache.get(cache_key)
45
- if rsa_value is not None:
46
- return rsa_value
47
- try:
+ with lock:
+ rsa_value = rsa_cache.get(cache_key)
+ if rsa_value is not None:
+ return rsa_value
48
rsa_value = get_key_pair_by_sql()
49
rsa_cache.set(cache_key, rsa_value)
50
- finally:
51
- lock.release()
52
return rsa_value
53
54
0 commit comments