X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/da32ae2a73012ce55cb89b2de9a4716b2800eee1..ed56c26720184ca3d07f452faf014e177f1a2c2f:/sdk/cwl/arvados_cwl/fsaccess.py diff --git a/sdk/cwl/arvados_cwl/fsaccess.py b/sdk/cwl/arvados_cwl/fsaccess.py index 34d9cea3a4..534a675525 100644 --- a/sdk/cwl/arvados_cwl/fsaccess.py +++ b/sdk/cwl/arvados_cwl/fsaccess.py @@ -4,6 +4,7 @@ import errno import urlparse import re import logging +import threading import ruamel.yaml as yaml @@ -25,13 +26,15 @@ class CollectionCache(object): self.api_client = api_client self.keep_client = keep_client self.collections = {} + self.lock = threading.Lock() def get(self, pdh): - if pdh not in self.collections: - logger.debug("Creating collection reader for %s", pdh) - self.collections[pdh] = arvados.collection.CollectionReader(pdh, api_client=self.api_client, - keep_client=self.keep_client) - return self.collections[pdh] + with self.lock: + if pdh not in self.collections: + logger.debug("Creating collection reader for %s", pdh) + self.collections[pdh] = arvados.collection.CollectionReader(pdh, api_client=self.api_client, + keep_client=self.keep_client) + return self.collections[pdh] class CollectionFsAccess(cwltool.stdfsaccess.StdFsAccess):