Conversation
In Python scripts, you can use DatabaseMapping instances directly to access a Spine DB. Running such scripts that make commits to the same DB in parallel will quickly run into issues where some database mappings get out-of-sync from the DB or multiple scripts try to commit same data. This commit implements a way to lock the database accross multiple processes when we have DB server running. The lock can be acquired by a new context manager that asks the server for a lock and blocks if the DB has been already locked.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #618 +/- ##
==========================================
+ Coverage 86.07% 86.15% +0.07%
==========================================
Files 83 83
Lines 11447 11475 +28
Branches 1635 1636 +1
==========================================
+ Hits 9853 9886 +33
+ Misses 1241 1238 -3
+ Partials 353 351 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR add
lock_dbcontext manager tospine_db_clientthat can be used in scripts that are executed as part of Spine Toolbox workflows. It locks a database mapping using DB server allowing the script to safely commit data even when executed in parallel.No associated issue.
Checklist before merging