Skip to content

Commit 68310c5

Browse files
committed
Fix - break long tree reading as soon as possible
1 parent e4d15c3 commit 68310c5

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

modules/draw/TTree.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ TDrawSelector.prototype.ShowProgress = function(value) {
4848
if ((value === undefined) || !Number.isFinite(value))
4949
return showProgress();
5050

51+
if (this._break) {
52+
treeShowProgress(this, 'Breaking ... ');
53+
return 'break';
54+
}
55+
5156
if (this.last_progress !== value) {
5257
const diff = value - this.last_progress;
5358
if (!this.aver_diff) this.aver_diff = diff;
@@ -66,7 +71,7 @@ TDrawSelector.prototype.ShowProgress = function(value) {
6671
else if (this.aver_diff < 0.01)
6772
ndig = 1;
6873

69-
treeShowProgress(this, this._break ? 'Breaking ... ' : `TTree draw ${(value * 100).toFixed(ndig)} % `);
74+
treeShowProgress(this, `TTree draw ${(value * 100).toFixed(ndig)} % `);
7075
};
7176

7277
/** @summary Draw result of tree drawing

modules/io.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,8 +2788,10 @@ class TFile {
27882788

27892789
const progress_offest = sum1 / sum_total, progress_this = (sum2 - sum1) / sum_total;
27902790
xhr.addEventListener('progress', oEvent => {
2791-
if (oEvent.lengthComputable)
2792-
progress_callback(progress_offest + progress_this * oEvent.loaded / oEvent.total);
2791+
if (oEvent.lengthComputable) {
2792+
if (progress_callback(progress_offest + progress_this * oEvent.loaded / oEvent.total) === 'break')
2793+
xhr.abort();
2794+
}
27932795
});
27942796
} else if (first_block_retry && isFunc(xhr.addEventListener)) {
27952797
xhr.addEventListener('progress', oEvent => {

modules/tree.mjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ class TDrawSelector extends TSelector {
14191419
const now = new Date().getTime();
14201420
if (now - this.lasttm > this.monitoring) {
14211421
this.lasttm = now;
1422-
if (this.progress_callback)
1422+
if (isFunc(this.progress_callback))
14231423
this.progress_callback(this.hist);
14241424
}
14251425
}
@@ -2240,7 +2240,7 @@ async function treeProcess(tree, selector, args) {
22402240

22412241
const portion = (handle.staged_prev + value * (handle.staged_now - handle.staged_prev)) /
22422242
(handle.process_max - handle.process_min);
2243-
handle.selector.ShowProgress(portion);
2243+
return handle.selector.ShowProgress(portion);
22442244
}
22452245

22462246
function ProcessBlobs(blobs, places) {
@@ -2399,7 +2399,10 @@ async function treeProcess(tree, selector, args) {
23992399
if (handle.process_max > handle.process_min)
24002400
portion = (handle.staged_prev - handle.process_min) / (handle.process_max - handle.process_min);
24012401

2402-
handle.selector.ShowProgress(portion);
2402+
if (handle.selector.ShowProgress(portion) === 'break') {
2403+
handle.selector.Terminate(true);
2404+
return resolveFunc(handle.selector);
2405+
}
24032406

24042407
handle.progress_showtm = new Date().getTime();
24052408

0 commit comments

Comments
 (0)