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
1731c16f
Commit
1731c16f
authored
8 years ago
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a lock on the adapter
To prevent modifying the set of instances while iterating over them.
parent
29091374
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
src/ZODB/mvccadapter.py
src/ZODB/mvccadapter.py
+17
-11
No files found.
src/ZODB/mvccadapter.py
View file @
1731c16f
...
@@ -61,11 +61,13 @@ class MVCCAdapter(Base):
...
@@ -61,11 +61,13 @@ class MVCCAdapter(Base):
def
__init__
(
self
,
storage
):
def
__init__
(
self
,
storage
):
Base
.
__init__
(
self
,
storage
)
Base
.
__init__
(
self
,
storage
)
self
.
_instances
=
set
()
self
.
_instances
=
set
()
self
.
_lock
=
threading
.
Lock
()
if
hasattr
(
storage
,
'registerDB'
):
if
hasattr
(
storage
,
'registerDB'
):
storage
.
registerDB
(
self
)
storage
.
registerDB
(
self
)
def
new_instance
(
self
):
def
new_instance
(
self
):
instance
=
MVCCAdapterInstance
(
self
)
instance
=
MVCCAdapterInstance
(
self
)
with
self
.
_lock
:
self
.
_instances
.
add
(
instance
)
self
.
_instances
.
add
(
instance
)
return
instance
return
instance
...
@@ -76,6 +78,7 @@ class MVCCAdapter(Base):
...
@@ -76,6 +78,7 @@ class MVCCAdapter(Base):
return
UndoAdapterInstance
(
self
)
return
UndoAdapterInstance
(
self
)
def
_release
(
self
,
instance
):
def
_release
(
self
,
instance
):
with
self
.
_lock
:
self
.
_instances
.
remove
(
instance
)
self
.
_instances
.
remove
(
instance
)
closed
=
False
closed
=
False
...
@@ -87,21 +90,24 @@ class MVCCAdapter(Base):
...
@@ -87,21 +90,24 @@ class MVCCAdapter(Base):
del
self
.
_storage
del
self
.
_storage
def
invalidateCache
(
self
):
def
invalidateCache
(
self
):
with
self
.
_lock
:
for
instance
in
self
.
_instances
:
for
instance
in
self
.
_instances
:
instance
.
_invalidateCache
()
instance
.
_invalidateCache
()
def
invalidate
(
self
,
transaction_id
,
oids
,
version
=
''
):
def
invalidate
(
self
,
transaction_id
,
oids
,
version
=
''
):
with
self
.
_lock
:
for
instance
in
self
.
_instances
:
for
instance
in
self
.
_instances
:
instance
.
_invalidate
(
oids
)
instance
.
_invalidate
(
oids
)
references
=
serialize
.
referencesf
transform_record_data
=
untransform_record_data
=
lambda
self
,
data
:
data
def
_invalidate_finish
(
self
,
oids
,
committing_instance
):
def
_invalidate_finish
(
self
,
oids
,
committing_instance
):
with
self
.
_lock
:
for
instance
in
self
.
_instances
:
for
instance
in
self
.
_instances
:
if
instance
is
not
committing_instance
:
if
instance
is
not
committing_instance
:
instance
.
_invalidate
(
oids
)
instance
.
_invalidate
(
oids
)
references
=
serialize
.
referencesf
transform_record_data
=
untransform_record_data
=
lambda
self
,
data
:
data
def
pack
(
self
,
pack_time
,
referencesf
):
def
pack
(
self
,
pack_time
,
referencesf
):
return
self
.
_storage
.
pack
(
pack_time
,
referencesf
)
return
self
.
_storage
.
pack
(
pack_time
,
referencesf
)
...
...
This diff is collapsed.
Click to expand it.
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