spring-shell
spring-shell copied to clipboard
Spring Shell: Long running Command execution interruption
I am using Spring Shell to run some long running command. Is there anyway to provide some text input to interrupt long running command?
e.g. i'm writing some data to file which is very time consuming task. By providing pause text i would like to pause writing data to file.
How can we achieve this using spring shell while command is invoked?
If you really want input text to be the cause of interruption, then you just need to have your command periodically poll for text input. If you want a signal to interrupt your command, then you need to somehow reconfigure the CTRL-C handling installed by Spring Shell and have it notify your command logic to stop.
Hope that helps
How can I pool for the text input while command is in progress? As command is in progress it is not taking any inputs until command action is completes. If possible Can you provide any sudo code to pool for the text?
Polling means that the code of the long running task must periodically look for input. In pseudo code, it means that it looks like
while (thereIsSomeWorkToDo()) {
lookForTextInput();
doATinyBitOfWork();
}
If you want a signal to interrupt your command, then you need to somehow reconfigure the CTRL-C handling installed by Spring Shell and have it notify your command logic to stop.
Could you elaborate a bit here? Where should I look for if I were to need CTRL-C to stop my ShellMethod and not the whole application? At the moment it's not intercepted at all during a loop from the method, by the way.
while (thereIsSomeWorkToDo()) { lookForTextInput(); doATinyBitOfWork(); }
I have tried this and now getting another problem. Its prompting the options two times.
Operation is paused.
Enter