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
0ed7579d
Commit
0ed7579d
authored
Jun 19, 2016
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
de-obfuscated some delicate locking code
parent
532fd78a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
16 deletions
+26
-16
src/ZODB/MappingStorage.py
src/ZODB/MappingStorage.py
+20
-16
src/ZODB/utils.py
src/ZODB/utils.py
+6
-0
No files found.
src/ZODB/MappingStorage.py
View file @
0ed7579d
...
...
@@ -261,24 +261,28 @@ class MappingStorage(object):
self
.
_commit_lock
.
release
()
# ZODB.interfaces.IStorage
@
ZODB
.
utils
.
locked
(
opened
)
def
tpc_begin
(
self
,
transaction
,
tid
=
None
):
# The tid argument exists to support testing.
if
transaction
is
self
.
_transaction
:
raise
ZODB
.
POSException
.
StorageTransactionError
(
"Duplicate tpc_begin calls for same transaction"
)
self
.
_lock
.
release
()
with
self
.
_lock
:
ZODB
.
utils
.
check_precondition
(
self
.
opened
)
# The tid argument exists to support testing.
if
transaction
is
self
.
_transaction
:
raise
ZODB
.
POSException
.
StorageTransactionError
(
"Duplicate tpc_begin calls for same transaction"
)
self
.
_commit_lock
.
acquire
()
self
.
_lock
.
acquire
()
self
.
_transaction
=
transaction
self
.
_tdata
=
{}
if
tid
is
None
:
if
self
.
_transactions
:
old_tid
=
self
.
_transactions
.
maxKey
()
else
:
old_tid
=
None
tid
=
ZODB
.
utils
.
newTid
(
old_tid
)
self
.
_tid
=
tid
with
self
.
_lock
:
self
.
_transaction
=
transaction
self
.
_tdata
=
{}
if
tid
is
None
:
if
self
.
_transactions
:
old_tid
=
self
.
_transactions
.
maxKey
()
else
:
old_tid
=
None
tid
=
ZODB
.
utils
.
newTid
(
old_tid
)
self
.
_tid
=
tid
# ZODB.interfaces.IStorage
@
ZODB
.
utils
.
locked
(
opened
)
...
...
src/ZODB/utils.py
View file @
0ed7579d
...
...
@@ -268,6 +268,12 @@ def mktemp(dir=None, prefix='tmp'):
os
.
close
(
handle
)
return
filename
def
check_precondition
(
precondition
):
if
not
precondition
():
raise
AssertionError
(
"Failed precondition: "
,
precondition
.
__doc__
.
strip
())
class
Locked
(
object
):
def
__init__
(
self
,
func
,
inst
=
None
,
class_
=
None
,
preconditions
=
()):
...
...
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