Skip to content

Commit 6970186

Browse files
GlassOfWhiskeymr-c
andauthored
Handle spurious ReceiveScatterOutput callbacks (#2051)
This commit fixes #2003 by handling spurious, repeated callbacks of the `receive_scatter_output` method of the `ReceiveScatterOutput` class. The reason of multiple awakenings has not been investigated deeply, though. In the future, a thorough examination of the `MultithreadedJobExecutor` logic may be necessary. --------- Co-authored-by: Michael R. Crusoe <[email protected]>
1 parent 18b8fdf commit 6970186

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cwltool/workflow_job.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
MutableMapping,
1111
MutableSequence,
1212
Optional,
13+
Set,
1314
Sized,
1415
Tuple,
1516
Union,
@@ -88,12 +89,17 @@ def __init__(
8889
) -> None:
8990
"""Initialize."""
9091
self.dest = dest
91-
self.completed = 0
92+
self._completed: Set[int] = set()
9293
self.processStatus = "success"
9394
self.total = total
9495
self.output_callback = output_callback
9596
self.steps: List[Optional[JobsGeneratorType]] = []
9697

98+
@property
99+
def completed(self) -> int:
100+
"""The number of completed internal jobs."""
101+
return len(self._completed)
102+
97103
def receive_scatter_output(self, index: int, jobout: CWLObjectType, processStatus: str) -> None:
98104
"""Record the results of a scatter operation."""
99105
for key, val in jobout.items():
@@ -108,10 +114,11 @@ def receive_scatter_output(self, index: int, jobout: CWLObjectType, processStatu
108114
if self.processStatus != "permanentFail":
109115
self.processStatus = processStatus
110116

111-
self.completed += 1
117+
if index not in self._completed:
118+
self._completed.add(index)
112119

113-
if self.completed == self.total:
114-
self.output_callback(self.dest, self.processStatus)
120+
if self.completed == self.total:
121+
self.output_callback(self.dest, self.processStatus)
115122

116123
def setTotal(
117124
self,

0 commit comments

Comments
 (0)