Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
f6a82983
Commit
f6a82983
authored
Dec 29, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add abstraction layer to allow other implementation of locking
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
4df7253c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
4 deletions
+20
-4
weblate/trans/filelock.py
weblate/trans/filelock.py
+20
-4
No files found.
weblate/trans/filelock.py
View file @
f6a82983
...
...
@@ -35,9 +35,9 @@ class FileLockException(Exception):
pass
class
FileLock
(
object
):
class
FileLock
Base
(
object
):
"""
A file locking mechanism for Unix systems based on flock
.
Base file locking class
.
It can be also used as a context-manager using with statement.
"""
...
...
@@ -63,11 +63,11 @@ class FileLock(object):
def
try_lock
(
self
,
handle
):
"""Tries to lock the file"""
fcntl
.
flock
(
handle
,
fcntl
.
LOCK_EX
|
fcntl
.
LOCK_NB
)
raise
NotImplementedError
(
)
def
unlock
(
self
,
handle
):
"""Unlocks lock"""
fcntl
.
flock
(
handle
,
fcntl
.
LOCK_UN
)
raise
NotImplementedError
(
)
def
acquire
(
self
):
"""
...
...
@@ -153,3 +153,19 @@ class FileLock(object):
lying around.
"""
self
.
release
()
class
FcntlFileLock
(
FileLockBase
):
"""
A file locking mechanism for Unix systems based on flock.
"""
def
try_lock
(
self
,
handle
):
"""Tries to lock the file"""
fcntl
.
flock
(
handle
,
fcntl
.
LOCK_EX
|
fcntl
.
LOCK_NB
)
def
unlock
(
self
,
handle
):
"""Unlocks lock"""
fcntl
.
flock
(
handle
,
fcntl
.
LOCK_UN
)
FileLock
=
FcntlFileLock
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment