Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Allow interruption of execution #237

Closed
lspector opened this issue Jun 25, 2019 · 12 comments
Closed

[Feature request] Allow interruption of execution #237

lspector opened this issue Jun 25, 2019 · 12 comments

Comments

@lspector
Copy link

@lspector lspector commented Jun 25, 2019

Interrupting execution of a long-running (possibly infinite) is a very desirable feature that I would love to have in Calva.

Shooting for the moon here, but if execution could be interrupted and information about the context of interruption printed (ideally the call stack and super super desirably the values of locals in each stack frame), then that would be truly fabulous.

@lspector

This comment has been minimized.

Copy link
Author

@lspector lspector commented Jul 14, 2019

Rationale: Without this feature, any infinite loop cannot be stopped without entirely quitting and restarting VSCode, losing context, etc. To continue working it is necessary not only to be able to regain control of the REPL but also to terminate execution of the process so that it doesn't consume CPU cycles, drain batteries, etc.

This can be necessary both for accidental infinite loops and for intentional very-long-running processes that the developer realizes aren't doing what was intended, and have to be stopped and restarted after editing code.

@bpringe

This comment has been minimized.

Copy link
Contributor

@bpringe bpringe commented Oct 31, 2019

@PEZ Isn't this now in the current version of Calva?

@PEZ

This comment has been minimized.

Copy link
Collaborator

@PEZ PEZ commented Oct 31, 2019

Indeed it is. Thanks to @cfehse !

@PEZ PEZ closed this Oct 31, 2019
@lspector

This comment has been minimized.

Copy link
Author

@lspector lspector commented Nov 1, 2019

How? I just started an infinite loop and don't see any way to interrupt it.

@bpringe

This comment has been minimized.

Copy link
Contributor

@bpringe bpringe commented Nov 1, 2019

Sorry, I should have specified! In the REPL window, press ctrl+d to interrupt a running evaluation. In the editor, I believe you can interrupt with this command:

image

@lspector

This comment has been minimized.

Copy link
Author

@lspector lspector commented Nov 1, 2019

ctrl+d does not appear to do anything for me, when stuck in an infinite loop in the REPL window, whether I've actually entered the code in the REPL window or selected it in an editor window and used the command that evaluates a selection in the REPL window.

It would be great if whatever actually does work would be easily discoverable. Ideally the same method for interrupting a running evaluation would also work no matter how/where one started it.

@bpringe bpringe reopened this Nov 1, 2019
@bpringe

This comment has been minimized.

Copy link
Contributor

@bpringe bpringe commented Nov 1, 2019

Will have to check this out later. CC @cfehse @PEZ

@bpringe

This comment has been minimized.

Copy link
Contributor

@bpringe bpringe commented Nov 1, 2019

@lspector Can you provide detailed reproduction steps (commands used, whether in editor or in REPL, etc)? That would be very helpful and much appreciated.

@lspector

This comment has been minimized.

Copy link
Author

@lspector lspector commented Nov 1, 2019

@bpinge:

  • Launch VS Code
  • Jack in Calva
  • In the REPL: (loop [] (println 'looping) (recur))
  • Try aborting with ctrl-d, no effect, CPU cranking
  • Try adding additional modifier keys, no effect
  • Try selecting "Calva: interrupt running Evaluations" from the command palette, no effect
@cfehse

This comment has been minimized.

Copy link
Contributor

@cfehse cfehse commented Nov 1, 2019

@lspector @bpringe

Yes that form creates intermediately 100% CPU utilization - so that nearly no keystroke gets through the message loop and the REPL window is constantly updating the output. Under this conditions no instantaneously interruption of the evaluations can be expected. If you are a bit patient and either close the REPL window (which will interrupt a running evaluation as well) or wait for the editor context menu or the command prompt to appear and then select there the Interrupt running Evaluations command the evaluation will be interrupted and CPU utilization will calm down quickly. My system was so busy that I wa even not able to record an animated GIF to show what's going on.

Try something less "brutal" like (while true (println "hello") (Thread/sleep 10)) and you see that the interruption works instantaneously if there are resources left on the system.

@lspector

This comment has been minimized.

Copy link
Author

@lspector lspector commented Nov 1, 2019

Thanks! This does work with the Interrupt running Evaluations command, even when I'm doing work in the loop rather than sleeping, as in:

(while true 
       (println (last (repeatedly 1000000 rand))))

However, ctrl-d doesn't seem to work in any case.

In any event, I agree this is a pretty good solution, once one knows about the interrupt command. I don't know if there's a way to make that more discoverable.

@cfehse

This comment has been minimized.

Copy link
Contributor

@cfehse cfehse commented Nov 1, 2019

@lspector ctrl+d works fine in the REPL window, in case the REPL window is focused. During my testing I had no problems.

In any event, I agree this is a pretty good solution, once one knows about the interrupt command. I don't know if there's a way to make that more discoverable.

That's a general Problem with all the keyboard shortcuts I think. We introduced the editor context menu to get an idea, which commands are available and in the REPL window there is a list with important command in the intro section. This may be easily be overlooked.

Anyway I will close this issue for now.

Thanks for your testing!

@cfehse cfehse closed this Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.