Why am I receiving "Futures in state 'unavailable'" error when using "fetchNext" in MATLAB R2022a?
11 views (last 30 days)
Show older comments
MathWorks Support Team
on 7 Nov 2023
Answered: MathWorks Support Team
on 8 Dec 2023
I am using a for loop to generate a list of Futures from "parfeval" as in this example:
for n = 1:10
if (mod(n,2) == 0)
parallelOut(n) = parfeval(@() 1, 1);
else
continue;
end
end
When I try to use "fetchNext" on the "parallelOut" array it generates this error:
Error using parallel.FevalFuture/fetchNext:
fetchNext cannot operate on Futures in state 'unavailable'.
How can I avoid this error?
Accepted Answer
MathWorks Support Team
on 7 Nov 2023
The 'unavailable' state occurs when a Future array is pre-allocated but a Future is not defined. Most operations will fail on Futures with the 'unavailable' state.
In the above example every odd element will be 'unavailable'.
To avoid 'unavailable' state Futures, only add defined Future elements to the array and do not skip defining entries. Alternatively, after creating the array, remove all Futures with the 'unavailable' state from the array before calling "fetchNext".
0 Comments
More Answers (0)
See Also
Categories
Find more on Background Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!