Add lock around dumps_function cache
Fixes
@@ -3234,14 +3234,18 @@ def execute_task(task):
cache_dumps = LRU(maxsize=100)
+_cache_lock = threading.Lock()
+
def dumps_function(func):
""" Dump a function to bytes, cache functions """
try:
+ with _cache_lock:
result = cache_dumps[func]
except KeyError:
result = pickle.dumps(func)
if len(result) < 100000:
+ with _cache_lock:
cache_dumps[func] = result
except TypeError: # Unhashable function
result = pickle.dumps(func)
