How to set a background pool to process-based instead of thread-based
Show older comments
I'm trying to read and write files in the background of my matlab app. However, when I run the function that I want executed in the background
pool = backgroundPool;
f = parfevalOnAll(pool, @fetchAndPrepareData,0,filePaths);
I get the error message
f(1).Error{1}
ans =
ParallelException with properties:
identifier: 'parallel:threadpool:DisallowedBuiltin'
message: 'Use of function fopen is not supported on a thread-based worker.'
cause: {}
remotecause: {[1×1 MException]}
stack: [3×1 struct]
Correction: []
I've done some small work previously using parpool where you can use parpool('threads') or parpool('local') to switch, but I can't seem to find a similar way of achieving this using a backgorund pool.
If people know of a different way to read/write files in the background I am also open for other ideas, but I really want it done in the background since the files takes a very long time to load and the user needs to work on each file for qutie some time so I want the reduce wait time for the user to a minimum by reading the next file while the user is performing the work.
Accepted Answer
More Answers (1)
Jixiong Su
on 25 Nov 2023
You can use
pool=parpool('Processes')
f = parfeval(pool, @fetchAndPrepareData,0,filePaths);
Categories
Find more on Parallel Computing Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!