natcap / invest

InVEST®: models that map and value the goods and services from nature that sustain and fulfill human life.
Apache License 2.0
163 stars 66 forks source link

Handle what happens when application exits with an invest subprocess running #873

Open davemfish opened 4 years ago

davemfish commented 4 years ago

An "are you sure you want to exit" warning might be good. Or even some options like "exit and cancel invest job" or "exit but let invest continue running" might be possible since invest is running in a spawned process.

There's also some state related to the recent session list that is left in an unexpected state when this happens, so that should be fixed.

dcdenu4 commented 4 years ago

This also makes me wonder what happens to an InVEST run when I close my laptop?

richpsharp commented 4 years ago

Similar to what happens to your food when you close your refrigerator door?

dcdenu4 commented 4 years ago

@davemfish does this issue handle the following feature?:

Doug launches an InVEST model and realizes that it is doomed from the start. To avoid waiting for however long it takes the model to fail he would like to Kill InVEST Process by clicking a button.

Currently we don't have that in the UI and I have to find a way to manually stop the process from task manager or the like.

davemfish commented 4 years ago

@dcdenu4 , I agree a cancel button would be useful. And it could be addressed along with other details in this issue. Making such a button reliable may be tricky. https://stackoverflow.com/questions/18694684/spawn-and-kill-a-process-in-node-js

davemfish commented 3 years ago

We added a cancel invest button in natcap/invest-workbench#50 , but we're still not explicitly terminating the invest process if the electron app closes.

phargogh commented 3 years ago

we're still not explicitly terminating the invest process if the electron app closes.

For a long-running modelling job, maybe that'd be ok?

Or, as an alternative, if the user requests that the workbench close but there's still something running, we could ask what the user wants to do about it. If the process priority is being set, we could run it in the background without too much effect on the user's desktop experience.

davemfish commented 2 years ago

At this point, this is no longer a bug. If the application exits, the invest processes continue running. As mentioned above, we could ask the user what to do at the point: end the invest jobs, keep them running, abort the workbench exit, etc.

But as-is, the user-experience is okay. As James suggested,

If the process priority is being set, we could run it in the background without too much effect on the user's desktop experience.

So we could consider setting a process priority.