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
2ed7f414
Commit
2ed7f414
authored
Dec 29, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share code for lock opening
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
7d5ca68d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
weblate/trans/filelock.py
weblate/trans/filelock.py
+6
-2
No files found.
weblate/trans/filelock.py
View file @
2ed7f414
...
...
@@ -57,6 +57,10 @@ class FileLock(object):
self
.
is_locked
=
False
self
.
handle
=
None
def
open_file
(
self
):
"""Opens lock file"""
return
os
.
open
(
self
.
lockfile
,
os
.
O_CREAT
|
os
.
O_WRONLY
)
def
acquire
(
self
):
"""
Acquire the lock, if possible.
...
...
@@ -72,7 +76,7 @@ class FileLock(object):
start_time
=
time
.
time
()
# Open file
self
.
handle
=
os
.
open
(
self
.
lockfile
,
os
.
O_CREAT
|
os
.
O_WRONLY
)
self
.
handle
=
self
.
open_file
(
)
# Try to acquire lock
while
True
:
...
...
@@ -94,7 +98,7 @@ class FileLock(object):
'''
Checks whether lock is locked.
'''
handle
=
os
.
open
(
self
.
lockfile
,
os
.
O_CREAT
|
os
.
O_WRONLY
)
handle
=
self
.
open_file
(
)
try
:
fcntl
.
flock
(
handle
,
fcntl
.
LOCK_EX
|
fcntl
.
LOCK_NB
)
fcntl
.
flock
(
handle
,
fcntl
.
LOCK_UN
)
...
...
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