Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eic_tools
Spack
Commits
af7b96c1
Commit
af7b96c1
authored
9 years ago
by
Todd Gamblin
Browse files
Options
Downloads
Patches
Plain Diff
Lock acquires return True/False depending on whether they got POSIX lock.
parent
ead8ac58
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/spack/llnl/util/lock.py
+15
-4
15 additions, 4 deletions
lib/spack/llnl/util/lock.py
with
15 additions
and
4 deletions
lib/spack/llnl/util/lock.py
+
15
−
4
View file @
af7b96c1
...
@@ -95,10 +95,15 @@ def acquire_read(self, timeout=_default_timeout):
...
@@ -95,10 +95,15 @@ def acquire_read(self, timeout=_default_timeout):
order, but the POSIX lock is held until all local read and
order, but the POSIX lock is held until all local read and
write locks are released.
write locks are released.
Returns True if it is the first acquire and actually acquires
the POSIX lock, False if it is a nested transaction.
"""
"""
if
self
.
_reads
==
0
and
self
.
_writes
==
0
:
self
.
_lock
(
fcntl
.
LOCK_SH
,
timeout
)
self
.
_reads
+=
1
self
.
_reads
+=
1
if
self
.
_reads
==
1
and
self
.
_writes
==
0
:
self
.
_lock
(
fcntl
.
LOCK_SH
,
timeout
)
return
True
return
False
def
acquire_write
(
self
,
timeout
=
_default_timeout
):
def
acquire_write
(
self
,
timeout
=
_default_timeout
):
...
@@ -107,10 +112,16 @@ def acquire_write(self, timeout=_default_timeout):
...
@@ -107,10 +112,16 @@ def acquire_write(self, timeout=_default_timeout):
Read and write locks can be acquired and released in arbitrary
Read and write locks can be acquired and released in arbitrary
order, but the POSIX lock is held until all local read and
order, but the POSIX lock is held until all local read and
write locks are released.
write locks are released.
Returns True if it is the first acquire and actually acquires
the POSIX lock, False if it is a nested transaction.
"""
"""
if
self
.
_writes
==
0
:
self
.
_lock
(
fcntl
.
LOCK_EX
,
timeout
)
self
.
_writes
+=
1
self
.
_writes
+=
1
if
self
.
_writes
==
1
:
self
.
_lock
(
fcntl
.
LOCK_EX
,
timeout
)
return
True
return
False
def
release_read
(
self
):
def
release_read
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment