readstruct getting error when attempt to run function in background
3 views (last 30 days)
Show older comments
Jeff Beckstead on 1 Feb 2022
I have reduced down a function that I want to run in the background. When run as a background process, I get the error message back
>> [result] = fetchOutputs(WatchID); result
Error using parallel.Future/fetchOutputs
One or more futures resulted in an error.
Error using readstruct (line 72)
Use of function cd is not supported on a thread-based worker. Use alternatives supported on the background pool.
The function code follows:
function [resultBack] = BruteForceWrapper(inputStr)
%This is a brute force loop for the PhoneProcessWatcher
%Trying to launch it in the background but getting errors so doing brute
resultBack = 'Starting';
systemXmlPath = 'D:\ThisSystem';
systemStruct = readstruct(fullfile( systemXmlPath,'Configuration.xml'));
debugLevel = systemStruct.ImageProcess.DebugLevel;
Code that is launching as background is below
WatchID = parfeval( backgroundPool, @BruteForceWrapper, 1, 'just text' );
Is this occuring with the readstruct as a background function? Is there an alternative that will work in a background run function?
Rik on 2 Feb 2022
Apparently it calls cd somewhere internally.
You could try reading the file will xmlread and parse to a struct with parseXML. I didn't try myself, so I don't know if that would result in the same problem.
Find more on Environment and Settings 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!