Example Does Not Work

I try to run the example. The second line of code workerToClient = parallel.pool.PollableDataQueue(Destination="any") gives me this error:
Error using parallel.pool.PollableDataQueue (line 28)
Too many input arguments.
I remove the Destination = "any" argument and that seems to get things working. But then I get to the for-loop in the example:
for idx = 1:5
send(clientToWorker, [idx rand]);
status = poll(workerToClient, inf)
end
and the computer locks up with no output. I force-quite (CTRL-C) and type
future.State
The result is 'finished'. It seems the process stopped and I never sent the stop message. Seems nothing I can do will keep the process running.

6 件のコメント

Walter Roberson
Walter Roberson 2025 年 11 月 26 日
parallel.pool.PollableDataQueue(Destination="any")
has been supported only since R2025a.
Walter Roberson
Walter Roberson 2025 年 11 月 26 日
You did not post enough context for us to be sure that clientToWorker and workerToClient have been created in ways compatible with the default destination.
William
William 2025 年 11 月 26 日
移動済み: Walter Roberson 2025 年 11 月 26 日
I see the matlab provided example did not attach to this question. My appoligies. I'll copy it here:
Typed into the matlab command window:
pool = parpool("Threads",1);
workerToClient = parallel.pool.PollableDataQueue(Destination="any"); % Except that I had to remove the Destination="any"
clientToWorker = parallel.pool.PollableDataQueue(Destination="any"); % to get the error messages to go away.
In a seperate (processData.m) file:
function out = processData(workerToClient,clientToWorker)
out = 0;
send(workerToClient,"Ready to receive data.");
while true
% Wait for a message
data = poll(clientToWorker,Inf);
if strcmp(data,"stop")
send(workerToClient,"Stopped processing data on worker.")
return
else
response = sprintf("Data %d received.",data(1));
send(workerToClient,response);
out = out+data(2);
pause(1);
end
end
end
Back to the command window:
future = parfeval(@processData,1,workerToClient,clientToWorker);
status = poll(workerToClient,inf)
for idx = 1:5
send(clientToWorker,[idx rand]);
status = poll(workerToClient,inf)
end
There's more code (to be typed at the command prompt) after this but matlab hangs at this point.
Walter Roberson
Walter Roberson 2025 年 11 月 26 日
That example is marked "Since R2025a". It is not expected to work in R2024b.
William
William 2025 年 11 月 28 日
Is there no way to do block a parallel process while it waits for data pre-2025a?
Walter Roberson
Walter Roberson 2025 年 11 月 28 日
You have to be careful about what you are polling, as there is no Destination="any"

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

リリース

R2024b

質問済み:

2025 年 11 月 26 日

コメント済み:

2025 年 11 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by