Grass triggering python exception on "onterminate" causing the GUI to hang

I did install grass and started it fro the command line.

> grass
Starting GRASS GIS...

          __________  ___   __________    _______________
         / ____/ __ \/   | / ___/ ___/   / ____/  _/ ___/
        / / __/ /_/ / /| | \__ \\_  \   / / __ / / \__ \
       / /_/ / _, _/ ___ |___/ /__/ /  / /_/ // / ___/ /
       \____/_/ |_/_/  |_/____/____/   \____/___//____/

Welcome to GRASS GIS 8.4.0

Launching <wxpython> GUI in the background, please wait...

That GUI does come up but it hangs. On the why, it does show in the Console window:

Exception in thread
Thread-1
:
Traceback (most recent call last):
  File "/usr/lib64/python3.13/threading.py", line 1041, in
_bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/usr/lib64/grass84/gui/wxpython/core/gthread.py",
line 151, in __run
    self.__run_backup()
    ~~~~~~~~~~~~~~~~~^^
  File "/usr/lib64/grass84/gui/wxpython/core/gthread.py",
line 105, in run
    onterminate=vars()["onterminate"],
                ~~~~~~^^^^^^^^^^^^^^^
KeyError: 'onterminate'
Exception in thread

So opened up /usr/lib64/grass84/gui/wxpython/core/gthread.py

     def run(self):
        while True:
            requestId, args, kwds = self.requestQ.get()
            for key in ("callable", "ondone", "userdata", "onterminate"):
                if key in kwds:
                    vars()[key] = kwds[key]
                    del kwds[key]
                else:
                    vars()[key] = None

            requestTime = time.time()

            ret = None
            exception = None
            time.sleep(0.01)

            self._terminate_evt = wxThdTerminate(
                onterminate=vars()["onterminate"],
                kwds=kwds,
                args=args,
                pid=requestId,
            )

The python exception is triggered on the 5 but last line.

I do not understand why this error is hit, I found vars() gives the __dict__ of the current module, class, instance.

So it looks to me in the begin of code 4 keys including ā€œonterminateā€ are copied from the kwds dict and if the key is not present it is gven the value None. I do not have a good explanation on why the some lines later ā€œonterminateā€ can not be found in the vars() dict.

What I would like to know if anybody else is running into this problem.

Have a look at this:

I believe this type of problems are best asked in the OSGeo discourse forum for GRASS:

1 Like

Thanks for the link report, that is exactly the problem.

I see the patch has been merged 5 Nov 2024 and landed in GRASS GIS 8.4.1. On build.opensuse.org Application:Geo/grass I see that the latest update was 10 months ago to 8.4.0 so that explains things.

On a side note, I did see quite some grass updates coming by:

> sudo grep 'Installing: grass-8.*END' /var/log/zypper.log | perl -pe "s#<.*\|##";
2025-06-15 22:30:37 Installing: grass-8.4.0-43.254.x86_64} END
2025-06-17 07:22:52 Installing: grass-8.4.0-43.257.x86_64} END
2025-06-18 20:09:42 Installing: grass-8.4.0-43.259.x86_64} END
2025-06-19 20:49:05 Installing: grass-8.4.0-43.260.x86_64} END
2025-06-20 22:03:34 Installing: grass-8.4.0-43.261.x86_64} END
2025-06-21 07:50:03 Installing: grass-8.4.0-43.262.x86_64} END

Even this morning grass was updated so before looking it up I assumed I was running with pretty recent code. Anyone knows why there are so frequent re-builds for grass?

Packages are rebuilt when any of their build dependencies change.

1 Like

And in the case of GRASS, apart from itself, its main dependencies (PROJ, GEOS, GDAL) are updated quite often.

1 Like