Skip to content

Commit c54b03b

Browse files
authored
Merge pull request #5 from chrisburr/less-cs-locking
Add DIRAC_FEWER_CFG_LOCKS environment variable
2 parents ef06220 + 4e2f33e commit c54b03b

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
matrix:
1111
python_version:
1212
- 2.7.13
13-
- 3.5
1413
- 3.6.8
1514
- 3.7
1615
- 3.8
16+
- 3.9
1717
steps:
1818
- uses: actions/checkout@v2
1919
- name: Prepare environment

.github/workflows/prepare_environment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -euo pipefail
33

44
PYTHON_VERSION=$1
5-
PYTHON_VERSION=2.7.13
5+
66
conda create --quiet -c conda-forge -c free -n test-env \
77
python="$PYTHON_VERSION" \
88
"pytest>=4.6" pylint pytest-cov pycodestyle \

src/diraccfg/cfg.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,19 @@ class Synchronizer(object):
4444
decorator making the call thread-safe"""
4545

4646
def __init__(self, lockName="", recursive=False):
47-
self.lockName = lockName
48-
if recursive:
49-
self.lock = threading.RLock()
50-
else:
51-
self.lock = threading.Lock()
47+
envVar = os.environ.get("DIRAC_FEWER_CFG_LOCKS", "no").lower()
48+
self.__locksEnabled = envVar not in ("y", "yes", "t", "true", "on", "1")
49+
if self.__locksEnabled:
50+
self.lockName = lockName
51+
if recursive:
52+
self.lock = threading.RLock()
53+
else:
54+
self.lock = threading.Lock()
5255

5356
def __call__(self, funcToCall):
57+
if not self.__locksEnabled:
58+
return funcToCall
59+
5460
def lockedFunc(*args, **kwargs):
5561
try:
5662
if self.lockName:

0 commit comments

Comments
 (0)