[GRASS-git] [OSGeo/grass] 79c476: init: Add retries and timeout to mapset locking (#...

Vaclav Petras noreply at github.com
Thu May 1 05:42:46 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 79c476972acd9c4e9195189b342c1438df94c11b
      https://github.com/OSGeo/grass/commit/79c476972acd9c4e9195189b342c1438df94c11b
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2025-05-01 (Thu, 01 May 2025)

  Changed paths:
    M lib/init/grass.md
    M lib/init/grass.py
    M python/grass/app/cli.py
    M python/grass/app/data.py
    M python/grass/script/setup.py
    M python/grass/script/tests/grass_script_setup_test.py

  Log Message:
  -----------
  init: Add retries and timeout to mapset locking (#5443)

This change introduces a timeout parameter in CLI which is enabled by default and makes GRASS wait if the mapset is locked.

Additionally, this adds timeout parameter also to the Python API, so this keeps feature parity between the two (with locking and force lock removal already in place since #5591). The automatic tests are using the Python API, but they are limited as they don't use multiple threads or processes.

This also introduces new subcommands to the experimental execution of the grass.app with CLI API using `python -m grass.app` from #5590. Specifically, lock and unlock subcommands are now available and can be used for testing (compensating for the limited automatic tests), fixing lock situations, and by external applications which need to persistently lock mapset without using the Python API directly. Subcommands are added to the first level, but could eventually be under a project or mapset subcommand.

Notably, the locking is disabled on Windows, so test is disabled for Windows.

The timeout implementation actually measures the elapsed time in addition to counting the theoretically waited time. While counting clearly ends the loop, the elapsed time may be significantly higher for some timeouts given that the lock process execution takes a second to execute when the mapset is locked as it waits (for a second) to make sure a PID is written to the file but the other process.



To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications


More information about the grass-commit mailing list