🎉 Adds the ability to cancel execution#103
Merged
AlexandreSajus merged 2 commits intomasterfrom Dec 9, 2021
Merged
Conversation
Contributor
Author
|
The test "run source code when run button is pressed." fails on github but succeeds in local, weird... |
Member
Yeah this is a known issue ... @vanyle know about it, maybe his solution will fix this |
MathisFederico
requested changes
Dec 8, 2021
Member
MathisFederico
left a comment
There was a problem hiding this comment.
Nice !
A small change and we are good to go !
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) |
Member
There was a problem hiding this comment.
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) |
opencodeblocks/blocks/codeblock.py
Outdated
Comment on lines
+153
to
+155
| if self.run_button.text() == "..." and not in_right_button: | ||
| self._interrupt_execution() | ||
|
|
Member
There was a problem hiding this comment.
Use return instead of if ... else in cases like this to avoid over-indentation
MathisFederico
approved these changes
Dec 9, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pressing a run button when it displays "..." interrupts the kernel and empties the execution queue
Fixes #52