Skip to content

Commit ec9c21f

Browse files
authored
Ensure not clobbering same file. Fixes #1842 (#1843)
* Ensure not clobbering same file. Fixes #1842 * Remove command file after execution
1 parent c4c4222 commit ec9c21f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/visualizers/widgets/TensorPlotter/TensorPlotterWidget.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ define([
3030
constructor(logger, container) {
3131
super(container);
3232
this._logger = logger.fork('Widget');
33+
this.cmdCount = 0;
3334
this.currentPlotData = null;
3435

3536
this.session = null;
@@ -95,8 +96,10 @@ define([
9596

9697
async execPy(code) {
9798
try {
98-
await this.session.addFile('last_cmd.py', code);
99-
const {stdout} = await this.session.exec('python last_cmd.py');
99+
const i = ++this.cmdCount;
100+
await this.session.addFile(`cmd_${i}.py`, code);
101+
const {stdout} = await this.session.exec(`python cmd_${i}.py`);
102+
await this.session.removeFile(`cmd_${i}.py`);
100103
return stdout;
101104
} catch (err) {
102105
const {stderr} = err.jobResult;

0 commit comments

Comments
 (0)