Skip to content

Commit

Permalink
Fix up lock handling in hgweb_config_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed May 29, 2024
1 parent b00beec commit 410ccb9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/tool_shed/util/hgweb_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class HgWebConfigManager:
def __init__(self):
self.hgweb_config_dir = None
self.in_memory_config = None
self.lock = threading.Lock()

def add_entry(self, lhs, rhs):
"""Add an entry in the hgweb.config file for a new repository."""
lock = threading.Lock()
lock.acquire(True)
self.lock.acquire(True)
try:
# Since we're changing the config, make sure the latest is loaded into memory.
self.read_config(force_read=True)
Expand All @@ -38,12 +38,11 @@ def add_entry(self, lhs, rhs):
except Exception as e:
log.debug("Exception in HgWebConfigManager.add_entry(): %s", unicodify(e))
finally:
lock.release()
self.lock.release()

def change_entry(self, old_lhs, new_lhs, new_rhs):
"""Change an entry in the hgweb.config file for a repository - this only happens when the owner changes the name of the repository."""
lock = threading.Lock()
lock.acquire(True)
self.lock.acquire(True)
try:
self.make_backup()
# Remove the old entry.
Expand All @@ -55,7 +54,7 @@ def change_entry(self, old_lhs, new_lhs, new_rhs):
except Exception as e:
log.debug("Exception in HgWebConfigManager.change_entry(): %s", unicodify(e))
finally:
lock.release()
self.lock.release()

def get_entry(self, lhs):
"""Return an entry in the hgweb.config file for a repository"""
Expand Down

0 comments on commit 410ccb9

Please sign in to comment.