[GRASS-dev] Cleanup when terminating modules from GUI

Stefan Blumentrath Stefan.Blumentrath at nina.no
Mon Oct 25 13:00:09 PDT 2021


Hi,

In an addon, I define an atexit procedure, that removes all temporary data that has a prefix defined by a global variable "TMPNAME".

This works nicely when I run the addon from the command line. Regardless if the module ends with or without success, all temporary data is cleaned up at the end properly.
However, when I run it through the GUI the cleanup method does not remove the temporary maps when the process fails or is aborted by the user...

Looking into the GUI code, it seems that if one presses the "Stop" button, the process is aborted with Popen().terminate(). That does not trigger the "atexit" function and additional signals would have to be caught, like e.g. here:
https://stackoverflow.com/questions/23468042/the-invocation-of-signal-handler-and-atexit-handler-in-python

What would be the proper way to address this? Adding a signal handler in addons? I did not see any way to terminate running modules from the GUI differently?
Would it be possible to add signal handling as a library function?

Cheers
Stefan


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20211025/a3f72e0f/attachment.html>


More information about the grass-dev mailing list