Merge pull request #387 from mcella/378

Fixes #378: must acquire JID_CACHE_LOCK before adding to JID_CACHE
This commit is contained in:
Mike Taylor 2015-07-31 11:21:01 -04:00
commit 2c69144189

View File

@ -72,9 +72,8 @@ JID_CACHE_LOCK = threading.Lock()
JID_CACHE_MAX_SIZE = 1024
def _cache(key, parts, locked):
JID_CACHE[key] = (parts, locked)
if len(JID_CACHE) > JID_CACHE_MAX_SIZE:
with JID_CACHE_LOCK:
JID_CACHE[key] = (parts, locked)
while len(JID_CACHE) > JID_CACHE_MAX_SIZE:
found = None
for key, item in JID_CACHE.items():