Skip to content

🎉 Adds the ability to cancel execution - #103

Merged
AlexandreSajus merged 2 commits into
masterfrom
feature/cancel-run
Dec 9, 2021
Merged

🎉 Adds the ability to cancel execution#103
AlexandreSajus merged 2 commits into
masterfrom
feature/cancel-run

Conversation

@AlexandreSajus

Copy link
Copy Markdown
Contributor

Pressing a run button when it displays "..." interrupts the kernel and empties the execution queue

Fixes #52

@AlexandreSajus AlexandreSajus self-assigned this Dec 8, 2021
@AlexandreSajus

Copy link
Copy Markdown
Contributor Author

The test "run source code when run button is pressed." fails on github but succeeds in local, weird...

@MathisFederico

Copy link
Copy Markdown
Member

The test "run source code when run button is pressed." fails on github but succeeds in local, weird...

Yeah this is a known issue ... @vanyle know about it, maybe his solution will fix this

@MathisFederico MathisFederico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice !
A small change and we are good to go !

Comment thread opencodeblocks/blocks/codeblock.py Outdated
Comment on lines +186 to +200
if self.run_all_button.text() == "...":
self._interrupt_execution()

else:
# If no output, run left
if not self.has_output():
return self.run_left(in_right_button=True)

# Same as run_left but instead of running the blocks, we'll use run_left
graph = self.scene().create_graph()
edges = bfs_edges(graph, self)
blocks_to_run: List["OCBCodeBlock"] = [
self] + [v for _, v in edges]
for block in blocks_to_run[::-1]:
block.run_left(in_right_button=True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use return instead of if ... else in cases like this to avoid overindentation

Suggested change
if self.run_all_button.text() == "...":
self._interrupt_execution()
else:
# If no output, run left
if not self.has_output():
return self.run_left(in_right_button=True)
# Same as run_left but instead of running the blocks, we'll use run_left
graph = self.scene().create_graph()
edges = bfs_edges(graph, self)
blocks_to_run: List["OCBCodeBlock"] = [
self] + [v for _, v in edges]
for block in blocks_to_run[::-1]:
block.run_left(in_right_button=True)
if self.run_all_button.text() == "...":
self._interrupt_execution()
return
# If no output, run left
if not self.has_output():
return self.run_left(in_right_button=True)
# Same as run_left but instead of running the blocks, we'll use run_left
graph = self.scene().create_graph()
edges = bfs_edges(graph, self)
blocks_to_run: List["OCBCodeBlock"] = [
self] + [v for _, v in edges]
for block in blocks_to_run[::-1]:
block.run_left(in_right_button=True)

Comment thread opencodeblocks/blocks/codeblock.py Outdated
Comment on lines +153 to +155
if self.run_button.text() == "..." and not in_right_button:
self._interrupt_execution()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use return instead of if ... else in cases like this to avoid over-indentation

@AlexandreSajus
AlexandreSajus merged commit 950d64a into master Dec 9, 2021
@AlexandreSajus
AlexandreSajus deleted the feature/cancel-run branch December 9, 2021 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cancel run button, loading animation

2 participants