Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
ca108917
Commit
ca108917
authored
Dec 03, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use default argument to specify exception.
Log message on platforms where file-locking isn't supported.
parent
aecc2d14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
src/ZODB/lock_file.py
src/ZODB/lock_file.py
+13
-12
No files found.
src/ZODB/lock_file.py
View file @
ca108917
...
@@ -12,25 +12,24 @@
...
@@ -12,25 +12,24 @@
#
#
##############################################################################
##############################################################################
import
POSException
from
ZODB.POSException
import
StorageSystemError
# Try to create a function that creates Unix file locks. On windows
# Try to create a function that creates Unix file locks.
# this will fail.
try
:
try
:
import
fcntl
import
fcntl
lock_file_FLAG
=
fcntl
.
LOCK_EX
|
fcntl
.
LOCK_NB
lock_file_FLAG
=
fcntl
.
LOCK_EX
|
fcntl
.
LOCK_NB
def
lock_file
(
file
,
error
=
POSException
.
StorageSystemError
):
def
lock_file
(
file
):
try
:
try
:
un
=
file
.
fileno
()
un
=
file
.
fileno
()
except
:
except
:
return
# don't care if not a real file
return
# don't care if not a real file
try
:
try
:
fcntl
.
flock
(
un
,
lock_file_FLAG
)
fcntl
.
flock
(
un
,
lock_file_FLAG
)
except
:
except
:
raise
e
rror
,
(
raise
StorageSystemE
rror
,
(
"Could not lock the database file. There must be
\
n
"
"Could not lock the database file. There must be
\
n
"
"another process that has opened the file.
\
n
"
"another process that has opened the file.
\
n
"
"<p>"
)
"<p>"
)
...
@@ -39,19 +38,21 @@ except:
...
@@ -39,19 +38,21 @@ except:
# Try windows-specific code:
# Try windows-specific code:
try
:
try
:
from
winlock
import
LockFile
from
winlock
import
LockFile
def
lock_file
(
file
,
error
=
POSException
.
StorageSystemError
):
def
lock_file
(
file
):
try
:
try
:
un
=
file
.
fileno
()
un
=
file
.
fileno
()
except
:
except
:
return
# don't care if not a real file
return
# don't care if not a real file
try
:
try
:
LockFile
(
un
,
0
,
0
,
1
,
0
)
# just lock the first byte, who cares
LockFile
(
un
,
0
,
0
,
1
,
0
)
# just lock the first byte, who cares
except
:
except
:
raise
e
rror
,
(
raise
StorageSystemE
rror
,
(
"Could not lock the database file. There must be
\
n
"
"Could not lock the database file. There must be
\
n
"
"another process that has opened the file.
\
n
"
"another process that has opened the file.
\
n
"
"<p>"
)
"<p>"
)
except
:
except
:
def
lock_file
(
file
,
error
=
None
):
import
zLOG
pass
def
lock_file
(
file
):
zLOG
.
LOG
(
"FS"
,
zLOG
.
INFO
,
"No file-locking support on this platform"
)
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