Request for Feature to Close the Mparallel in between
Closed this issue · 3 comments
Request for Feature to Close ( Break ) the Mparallel process in between when running.
Currently, it Disables the Close Button when Process is running.
Sometimes when the process is quite long enough & it is required to break in between. It would be very much helpful if it is done,
Hello,
in fact this already is implemented:
MParallel properly installs an application-defined HandlerRoutine into the terminal window, via SetConsoleCtrlHandler, so that "Ctrl+C" and "Close" events are recognized. If such an event is recognized, an internal "interrupted" flag is set, which means that the batch processing is stopped at that point. Jobs (processes) that already are running will not forcefully be terminated though – which probably is the right thing to do for most scenarios! You can use option --timeout
to specify a timeout for long-running processes. Jobs (processes) that exceed the timeout will be terminated.
Regards.
First of All, Thanks a lot for making such product.... & also the above Suggestion & Feedback.
However, we face situation where we need to terminate in between.
It is just a humble request if close button can be enabled to terminate in between whenever required to terminate for some reason..
( & also not all users that much tech savvy who can understand to press even CTRL+C.... )
I have to correct: When an interrupt is signaled, e.g. by pressing Ctrl+C
, an thus the internal "interrupted" flag is raised by the HandlerRoutine, then MParallel will exit from its "main" processing loop right away. Then, in the final clean-up, all processes (tasks) that are still running will be terminated.
Maybe this will be reconsidered in a future version.
Anyway, as things stand, you can simply press Ctrl+C
to abort all running tasks immediately; as well as all tasks that have not been started yet. Furthermore, I think Ctrl+C
has been the standard way to interrupt running processes for decades – probably since the first Unix systems from the late 1960's – so everybody who has ever been working with the terminal can be expected to be familiar with it. Since MParallel is a tool for advanced terminal applications, this especially applies to MParallel users 😏
BTW: The reason why we disable the "X" (Close) button of the console window is because if the user clicks the "X" (Close) button, then Windows will force our process to be terminated – no matter what. This cannot be intercepted by the console process, so we won't be able to do a proper clean-up.
If you really want to remove/disable this "feature", then you'd have to comment out one line:
https://github.com/lordmulder/MParallel/blob/master/src/Utils.cpp#L248
(But it would probably mean that, as soon as you click the "X" button, it will terminate the MParallel process immediately, leaving the child processes – if any – "orphaned" but still running)