Skip to content

Commit

Permalink
🩹 Queued vs running patches
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Sep 6, 2020
1 parent 4d0bf17 commit cc7248d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
25 changes: 15 additions & 10 deletions frontend/common/Feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,23 @@ export const finalize_statistics = async (state, client, counter_statistics) =>
...counter_statistics,
}

let { message } = await client.send("get_all_notebooks")
statistics.numConcurrentNotebooks = message.notebooks.length
try {
let { message } = await client.send("get_all_notebooks")
statistics.numConcurrentNotebooks = message.notebooks.length

await fetch("ping")
const ticHTTP = Date.now()
await fetch("ping")
statistics.pingTimeHTTP = Date.now() - ticHTTP
await fetch("ping")
const ticHTTP = Date.now()
await fetch("ping")
statistics.pingTimeHTTP = Date.now() - ticHTTP

await client.send("get_version")
const ticWS = Date.now()
await client.send("get_version")
statistics.pingTimeWS = Date.now() - ticWS
await client.send("get_version")
const ticWS = Date.now()
await client.send("get_version")
statistics.pingTimeWS = Date.now() - ticWS
} catch (ex) {
console.log("Failed to measure ping times")
console.log(ex)
}

return statistics
}
Expand Down
17 changes: 9 additions & 8 deletions frontend/components/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ export class Editor extends Component {
...this.state.notebook,
cells: update.message.cells.map((cell) => {
const cell_data = empty_cell_data(cell.cell_id)
cell_data.running = run_all
cell_data.running = false
cell_data.queued = run_all
cell_data.code_folded = true
return cell_data
}),
Expand All @@ -264,7 +265,7 @@ export class Editor extends Component {
).then((updates) => {
updates.forEach((u, i) => {
const cell_data = this.state.notebook.cells[i]
if (!run_all || cell_data.running) {
if (!run_all || cell_data.running || cell_data.queued) {
this.actions.update_local_cell_output(cell_data, u.message)
} else {
// the cell completed running asynchronously, after Pluto received and processed the :getouput request, but before this message was added to this client's queue.
Expand Down Expand Up @@ -393,7 +394,7 @@ export class Editor extends Component {
set_notebook_state((prevstate) => {
return {
cells: prevstate.cells.map((c) => {
return { ...c, errored: c.errored || c.running }
return { ...c, errored: c.errored || c.running || c.queued }
}),
}
})
Expand Down Expand Up @@ -451,7 +452,7 @@ export class Editor extends Component {
})

set_cell_state(cell_id, {
running: true,
queued: true,
}).then(() => {
this.actions.update_local_cell_input(cell, false, "", true)
})
Expand All @@ -468,7 +469,7 @@ export class Editor extends Component {
},
confirm_delete_multiple: (cells) => {
if (cells.length <= 1 || confirm(`Delete ${cells.length} cells?`)) {
if (cells.some((f) => f.running)) {
if (cells.some((f) => f.running || f.queued)) {
if (confirm("This cell is still running - would you like to interrupt the notebook?")) {
this.requests.interrupt_remote(cells[0].cell_id)
}
Expand All @@ -494,7 +495,7 @@ export class Editor extends Component {
},
set_and_run_multiple: (cells) => {
const promises = cells.map((cell) => {
set_cell_state(cell.cell_id, { running: true })
set_cell_state(cell.cell_id, { queued: true })
return this.client
.send(
"set_input",
Expand Down Expand Up @@ -614,7 +615,7 @@ export class Editor extends Component {
switch (e.keyCode) {
case 81: // q
if (e.ctrlKey) {
if (this.state.notebook.cells.some((c) => c.running)) {
if (this.state.notebook.cells.some((c) => c.running || c.queued)) {
this.requests.interrupt_remote()
}
e.preventDefault()
Expand Down Expand Up @@ -721,7 +722,7 @@ export class Editor extends Component {
document.body.classList.add("disconnected")
}

const all_completed_now = !this.state.notebook.cells.some((cell) => cell.running)
const all_completed_now = !this.state.notebook.cells.some((cell) => cell.running || cell.queued)
if (all_completed_now && !this.all_completed) {
this.all_completed = true
this.all_completed_promise.resolve()
Expand Down
1 change: 1 addition & 0 deletions frontend/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ body > header.show_export {
}

aside#export {
overflow-x: hidden;
position: absolute;
top: -1130px;
width: 100%;
Expand Down

0 comments on commit cc7248d

Please sign in to comment.