Release web plot request lock after errors
This commit is contained in:
1 parent
ce2a544ab8
commit
6a80c5df80
2 files changed
+60
-46
No files matched your search
+56
-46
@@ -881,59 +881,69 @@ function showWebRootPlotWindow(rootUrls, jobName = "", plotContext = {}) {
|
||||
|
||||
rootPlotRequestInProgress = true;
|
||||
let requestLabel = (averaged ? "averaged " : "") + (fft ? "FFT " : "") + "ROOT plot";
|
||||
if (typeof updateJobStatus === "function") {
|
||||
updateJobStatus({
|
||||
state: "Running musrview",
|
||||
message: "Generating " + requestLabel,
|
||||
finishedAt: "",
|
||||
exitCode: ""
|
||||
try {
|
||||
if (typeof updateJobStatus === "function") {
|
||||
updateJobStatus({
|
||||
state: "Running musrview",
|
||||
message: "Generating " + requestLabel,
|
||||
finishedAt: "",
|
||||
exitCode: ""
|
||||
});
|
||||
}
|
||||
|
||||
let request = await postToMusrfitCGI({
|
||||
action: "run",
|
||||
fn: plotContext.msrPath,
|
||||
use_msr2data: 0,
|
||||
runs: plotContext.runs || "",
|
||||
template_name: "",
|
||||
base_run: "",
|
||||
fftv: fft ? "y" : "n",
|
||||
avgv: averaged ? "y" : "n",
|
||||
plot_only: 1,
|
||||
plot_refresh: 1
|
||||
});
|
||||
}
|
||||
let response = request.payload;
|
||||
let rootUrls = musrfitRootUrlsFromResponse(response);
|
||||
let specs = normalizeMusrfitRootPlotSpecs(rootUrls,
|
||||
response && Array.isArray(response.root_items) ? response.root_items : []);
|
||||
|
||||
let request = await postToMusrfitCGI({
|
||||
action: "run",
|
||||
fn: plotContext.msrPath,
|
||||
use_msr2data: 0,
|
||||
runs: plotContext.runs || "",
|
||||
template_name: "",
|
||||
base_run: "",
|
||||
fftv: fft ? "y" : "n",
|
||||
avgv: averaged ? "y" : "n",
|
||||
plot_only: 1,
|
||||
plot_refresh: 1
|
||||
});
|
||||
let response = request.payload;
|
||||
let rootUrls = musrfitRootUrlsFromResponse(response);
|
||||
let specs = normalizeMusrfitRootPlotSpecs(rootUrls,
|
||||
response && Array.isArray(response.root_items) ? response.root_items : []);
|
||||
|
||||
if (response && response.command_log && typeof appendJobLog === "function") {
|
||||
appendJobLog(response.command_log.trim());
|
||||
}
|
||||
|
||||
if (!request.ok || !response || !response.ok || !specs.length) {
|
||||
let errorMessage = request.error || (response ? response.message : "Plot request failed");
|
||||
if (response && response.stderr) {
|
||||
errorMessage += "\n" + response.stderr.trim();
|
||||
if (response && response.command_log && typeof appendJobLog === "function") {
|
||||
appendJobLog(response.command_log.trim());
|
||||
}
|
||||
|
||||
if (!request.ok || !response || !response.ok || !specs.length) {
|
||||
let errorMessage = request.error || (response ? response.message : "Plot request failed");
|
||||
if (response && response.stderr) {
|
||||
errorMessage += "\n" + response.stderr.trim();
|
||||
}
|
||||
if (typeof finishJobStatus === "function") {
|
||||
finishJobStatus(0, response && response.code !== undefined ? response.code : 1,
|
||||
errorMessage);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
rootSpecCache[key] = specs.slice();
|
||||
rootDecodeCaches[key] = new Map();
|
||||
applyRootPlotView(fft, averaged, rootSpecCache[key], {
|
||||
plotPath: specs[0].url
|
||||
});
|
||||
if (typeof finishJobStatus === "function") {
|
||||
finishJobStatus(0, response && response.code !== undefined ? response.code : 1,
|
||||
errorMessage);
|
||||
finishJobStatus(1, response.code !== undefined ? response.code : 0,
|
||||
response.message || (requestLabel.charAt(0).toUpperCase()
|
||||
+ requestLabel.slice(1) + " completed"));
|
||||
}
|
||||
} catch (error) {
|
||||
let errorMessage = error && error.message ? error.message : String(error);
|
||||
if (typeof finishJobStatus === "function") {
|
||||
finishJobStatus(0, 1, "Could not generate " + requestLabel + ": " + errorMessage);
|
||||
}
|
||||
} finally {
|
||||
// A transport, decoding, or rendering exception must not leave this
|
||||
// plot window permanently unable to request another view.
|
||||
rootPlotRequestInProgress = false;
|
||||
return;
|
||||
}
|
||||
|
||||
rootSpecCache[key] = specs.slice();
|
||||
rootDecodeCaches[key] = new Map();
|
||||
applyRootPlotView(fft, averaged, rootSpecCache[key], {
|
||||
plotPath: specs[0].url
|
||||
});
|
||||
if (typeof finishJobStatus === "function") {
|
||||
finishJobStatus(1, response.code !== undefined ? response.code : 0,
|
||||
response.message || (requestLabel.charAt(0).toUpperCase() + requestLabel.slice(1) + " completed"));
|
||||
}
|
||||
rootPlotRequestInProgress = false;
|
||||
}
|
||||
|
||||
async function toggleMusrfitRootFFT() {
|
||||
|
||||
@@ -399,6 +399,10 @@ function testDecodeCache() {
|
||||
assert.match(code, /rootDecodeCaches\[key\] = new Map\(\)/);
|
||||
assert.match(code, /function currentDecodeCache\(\)/);
|
||||
assert.match(code, /spectrum:n/);
|
||||
assert.match(code, /renderMusrfitRootPlots\(plotContainer, currentSpecs, version, rootViewMode, rootDecodeCaches\[key\]\)/);
|
||||
assert.match(code,
|
||||
/catch \(error\)[\s\S]*Could not generate[\s\S]*finally[\s\S]*rootPlotRequestInProgress = false/,
|
||||
"failed ROOT transformations report the error and always release the request lock");
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
|
||||
Reference in new issue
Block a user