-
-
Notifications
You must be signed in to change notification settings - Fork 361
init: Add retries and timeout to mapset locking #5443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… the max tries, focusing on timeout
…ting 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.
I need to fix the tests...there is no locking on Windows. Otherwise the tests pass. |
Isn't this starting to be three PRs at once? At least for the cli changes, that are great by themselves. (I already explored similar changes like two years ago when starting to work on modernizing gunittest, syncing with upstream unittest, but wasn't completed as no way to fully validate if it there would be impacts on tests on all our platforms, as that the tests were not all running or would allow failures on some platforms). But the |
And if you are up to fixing some tests, maybe update the branch that is 108 commits behind, I’ve made some progress on this part recently. And more to come. |
I can split that, adding the locking to init without a timeout. The reason I did only one is that init and CLI should have feature parity and the |
From digging the history quite often, I know that following renames+changes are quite hard. The CLI main part could go right through, and then add on the options? |
This PR does not have a rename, no? |
Indeed, I looked at the commits of yesterday, and thought that 0a2887f was moving code around from |
I have now WIP to introduce the internal CLI with just simple help functionality and I'll later split also the Python locking addition to a separate PR. |
This adds a CLI to grass.app subpackage using `__main__.py` and Python argparse with subcommands. At this point, this is meant as internal and experimental. The original motivation for this is testing locking in OSGeo#5443. The subcommands add a lot of flexibility in what can done with argparse supporting directly several use cases and being quite stable and standardized. Just as an example (to have this separate from OSGeo#5443 while functional), this adds two subcommands, help and man, which both end up calling g.manual.
This adds a CLI to grass.app subpackage using `__main__.py` and Python argparse with subcommands. At this point, this is meant as internal and experimental. The original motivation for this is testing locking in #5443. The subcommands add a lot of flexibility in what can done with argparse supporting directly several use cases and being quite stable and standardized. Just as an example (to have this separate from #5443 while functional), this adds two subcommands, help and man, which both end up calling g.manual. These specific subcommands are not a replacement for calling g.manual inside an interactive shell, but there are a replacement for command line call with a temporary project setup.
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.
Locked mapset example in CLI:
Lock in Python (also works as a context manager):
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.Example lock-unlock (path to Python packages needs to be setup, don't ask me why LD_LIBRARY_PATH does not need to be setup - but it is needed for test of the Python API):
Notably, the locking is disabled on Windows, so test is disabled for Windows.