readstruct getting error when attempt to run function in background

4 views (last 30 days)
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.
Caused by:
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
%force
resultBack = 'Starting';
systemXmlPath = 'D:\ThisSystem';
systemStruct = readstruct(fullfile( systemXmlPath,'Configuration.xml'));
debugLevel = systemStruct.ImageProcess.DebugLevel;
end
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?

Answers (1)

Rik
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.

Categories

Find more on Entering Commands in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!