Skip to content

Commit dccabc8

Browse files
authored
Merge pull request #12294 from DeterminateSystems/fix-thread-pool-error
processGraph(): Don't throw ThreadPoolShutDown if there is an exception
2 parents 263a818 + a8c69cc commit dccabc8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/libutil/thread-pool.hh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,16 @@ void processGraph(
150150
}
151151
};
152152

153-
for (auto & node : nodes)
154-
pool.enqueue(std::bind(worker, std::ref(node)));
153+
for (auto & node : nodes) {
154+
try {
155+
pool.enqueue(std::bind(worker, std::ref(node)));
156+
} catch (ThreadPoolShutDown &) {
157+
/* Stop if the thread pool is shutting down. It means a
158+
previous work item threw an exception, so process()
159+
below will rethrow it. */
160+
break;
161+
}
162+
}
155163

156164
pool.process();
157165

0 commit comments

Comments
 (0)