Skip to content

Commit d5a52a5

Browse files
committed
cache: add threadsafety to pending output
1 parent 7c0cf8f commit d5a52a5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cwltool/command_line_tool.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import re
1010
import shutil
1111
import tempfile
12+
import threading
1213
from functools import cmp_to_key, partial
1314
from typing import (Any, Callable, Dict, # pylint: disable=unused-import
1415
Generator, List, Optional, Set, Text, Type, TYPE_CHECKING,
@@ -295,10 +296,10 @@ def job(self,
295296
separateDirs=False)
296297
_check_adjust = partial(check_adjust, cachebuilder)
297298
visit_class([cachebuilder.files, cachebuilder.bindings],
298-
("File", "Directory"), _check_adjust)
299+
("File", "Directory"), _check_adjust)
299300

300301
cmdline = flatten(list(map(cachebuilder.generate_arg, cachebuilder.bindings)))
301-
(docker_req, docker_is_req) = self.get_requirement("DockerRequirement")
302+
(docker_req, _) = self.get_requirement("DockerRequirement")
302303
if docker_req and runtimeContext.use_container:
303304
dockerimg = docker_req.get("dockerImageId") or docker_req.get("dockerPull")
304305
elif runtimeContext.default_container is not None and runtimeContext.use_container:
@@ -346,7 +347,8 @@ def job(self,
346347
keydictstr, cachekey)
347348

348349
jobcache = os.path.join(runtimeContext.cachedir, cachekey)
349-
jobcachepending = jobcache + ".pending"
350+
jobcachepending = "{}.{}.pending".format(
351+
jobcache, threading.current_thread().ident)
350352

351353
if os.path.isdir(jobcache) and not os.path.isfile(jobcachepending):
352354
if docker_req and runtimeContext.use_container:

0 commit comments

Comments
 (0)