readstruct getting error when attempt to run function in background

조회 수: 2 (최근 30일)
Jeff Beckstead
Jeff Beckstead 2022년 2월 1일
답변: Rik 2022년 2월 2일
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?

답변 (1개)

Rik
Rik 2022년 2월 2일
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.

카테고리

Help CenterFile Exchange에서 Platform and License에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by