aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-10-06 16:13:26 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-10-06 16:13:26 -0400
commitd9cad9011218fb192bd171c4be80688f5b845e4f (patch)
tree97c668b973043bcab07fd3f8ebae8b8a7266c2e9
parentf61504244bfe18c3cba18de83c19f51d9ebeae56 (diff)
downloadkorg-helpers-d9cad9011218fb192bd171c4be80688f5b845e4f.tar.gz
git-patchwork-bot: use a global lock
When running operations that require the shared cache database, make sure that only a single instance of the bot is running. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-xgit-patchwork-bot.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/git-patchwork-bot.py b/git-patchwork-bot.py
index 640f7f2..62a44be 100755
--- a/git-patchwork-bot.py
+++ b/git-patchwork-bot.py
@@ -1052,13 +1052,6 @@ def pwrun(repo, rsettings):
logger.info('Could not get the latest ref in %s', repo)
sys.exit(1)
- try:
- lockfh = open(os.path.join(repo, '.pwrun.lock'), 'w')
- lockf(lockfh, LOCK_EX | LOCK_NB)
- except IOError:
- logger.debug('Could not obtain an exclusive lock, assuming another process is running.')
- return
-
# Do we have a pw.db there yet?
dbpath = os.path.join(repo, 'pw.db')
db_exists = os.path.isfile(dbpath)
@@ -1288,7 +1281,14 @@ def pwrun(repo, rsettings):
def check_repos():
- # First, we run all repositories
+ # Use a global lock to make sure only a single process is running
+ try:
+ lockfh = open(os.path.join(CACHEDIR, 'patchwork-bot.global.lock'), 'w')
+ lockf(lockfh, LOCK_EX | LOCK_NB)
+ except IOError:
+ logger.info('Could not obtain an exclusive lock, assuming another process is running.')
+ sys.exit(0)
+
for repo in CONFIG['repos']:
fullpath = os.path.join(cmdargs.reposdir.rstrip('/'), repo.lstrip('/'))
if not os.path.isdir(fullpath):