Program stuck in a while loop
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I am using MATLAB to connect with the MONEY.NET API, they have a function to import financial news, it looks like this:
symbols = ["AAPL" "MSFT" "TSLA"]
N = numel(symbols)
for i = 1:N
connection = moneynet(username,pwd);
news = news(connection,'Number',5,'Symbol',symbol(i));
end
The thing is... I am actually scanning a lot more than 3 symbols, the list is over 1400 and sometimes one of the symbols gets removed from MONEY.NET or something so the news function gets stuck in a while loop, this just keeps running infinitely:
%Send the request
this.Connection.sendNewsRequest(num2str(num));
emptyFlag = true;
while emptyFlag
newsResponse = cell(this.Connection.getNewsResponse());
if strcmp(newsResponse,moneynet.Disconnected)
flagNoConnection(this);
end
emptyFlag = numel(newsResponse) == 1 && strcmp(newsResponse{1,1},moneynet.NoResponse);
end
So I'm having trouble with that because:
1) It's not a function I have written or have control of
2) It runs perfectly except for certain symbols in the loop
3) The loop gets stuck inside the news function if the symbol is not good
So I have to manually go over 1400 symbols and check which one gets the code stuck, I am sure there is a way to either check the symbols or have the program break out whenever it gets stuck (let's say if a loop takes over 5-10 seconds then continue to the next iteration or something)
I will be very thankful for any help here!
THX!!!
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Money.Net 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!