File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 191
191
# NOTE: once v1.12 releases we should switch this to wait(t; throw=false)
192
192
wait_nothrow (t) = Base. _wait (t)
193
193
194
+
195
+ """
196
+ empty_collection_error(task)
197
+
198
+ Check if a task failed due to an empty collection error.
199
+ """
200
+ function empty_collection_error end
201
+
202
+ @static if VERSION < v " 1.11.0-"
203
+ function empty_collection_error (task)
204
+ task. result isa MethodError && task. result. f == Base. mapreduce_empty
205
+ end
206
+ else
207
+ function empty_collection_error (task)
208
+ task. result isa ArgumentError &&
209
+ task. result. msg ==
210
+ " reducing over an empty collection is not allowed; consider supplying `init` to the reducer"
211
+ end
212
+ end
213
+
194
214
# GreedyScheduler w/o chunking
195
215
function _tmapreduce (f,
196
216
op,
@@ -230,7 +250,7 @@ function _tmapreduce(f,
230
250
filtered_tasks = filter (tasks) do stabletask
231
251
task = stabletask. t
232
252
istaskdone (task) || wait_nothrow (task)
233
- if task. result isa MethodError && task . result . f == Base . mapreduce_empty
253
+ if empty_collection_error ( task)
234
254
false
235
255
else
236
256
true
@@ -277,7 +297,7 @@ function _tmapreduce(f,
277
297
filtered_tasks = filter (tasks) do stabletask
278
298
task = stabletask. t
279
299
istaskdone (task) || wait_nothrow (task)
280
- if task. result isa MethodError && task . result . f == Base . mapreduce_empty
300
+ if empty_collection_error ( task)
281
301
false
282
302
else
283
303
true
You can’t perform that action at this time.
0 commit comments