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
87b26549
Commit
87b26549
authored
Nov 13, 2017
by
Julien Muchembled
Committed by
GitHub
Nov 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #181 from zopefoundation/closure
Review Connection/DB closure
parents
cb928231
d71f76d8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
23 deletions
+19
-23
src/ZODB/Connection.py
src/ZODB/Connection.py
+10
-16
src/ZODB/DB.py
src/ZODB/DB.py
+9
-7
No files found.
src/ZODB/Connection.py
View file @
87b26549
...
@@ -283,7 +283,6 @@ class Connection(ExportImport, object):
...
@@ -283,7 +283,6 @@ class Connection(ExportImport, object):
raise
ConnectionStateError
(
"Cannot close a connection joined to "
raise
ConnectionStateError
(
"Cannot close a connection joined to "
"a transaction"
)
"a transaction"
)
if
self
.
_cache
is
not
None
:
self
.
_cache
.
incrgc
()
# This is a good time to do some GC
self
.
_cache
.
incrgc
()
# This is a good time to do some GC
# Call the close callbacks.
# Call the close callbacks.
...
@@ -734,8 +733,6 @@ class Connection(ExportImport, object):
...
@@ -734,8 +733,6 @@ class Connection(ExportImport, object):
def
newTransaction
(
self
,
transaction
,
sync
=
True
):
def
newTransaction
(
self
,
transaction
,
sync
=
True
):
self
.
_readCurrent
.
clear
()
self
.
_readCurrent
.
clear
()
try
:
self
.
_storage
.
sync
(
sync
)
self
.
_storage
.
sync
(
sync
)
invalidated
=
self
.
_storage
.
poll_invalidations
()
invalidated
=
self
.
_storage
.
poll_invalidations
()
if
invalidated
is
None
:
if
invalidated
is
None
:
...
@@ -743,8 +740,6 @@ class Connection(ExportImport, object):
...
@@ -743,8 +740,6 @@ class Connection(ExportImport, object):
# we need to flush the whole cache.
# we need to flush the whole cache.
invalidated
=
self
.
_cache
.
cache_data
.
copy
()
invalidated
=
self
.
_cache
.
cache_data
.
copy
()
self
.
_cache
.
invalidate
(
invalidated
)
self
.
_cache
.
invalidate
(
invalidated
)
except
AttributeError
:
assert
self
.
_storage
is
None
def
afterCompletion
(
self
,
transaction
):
def
afterCompletion
(
self
,
transaction
):
# Note that we we call newTransaction here for 2 reasons:
# Note that we we call newTransaction here for 2 reasons:
...
@@ -924,7 +919,6 @@ class Connection(ExportImport, object):
...
@@ -924,7 +919,6 @@ class Connection(ExportImport, object):
transaction_manager
.
registerSynch
(
self
)
transaction_manager
.
registerSynch
(
self
)
if
self
.
_cache
is
not
None
:
self
.
_cache
.
incrgc
()
# This is a good time to do some GC
self
.
_cache
.
incrgc
()
# This is a good time to do some GC
if
delegate
:
if
delegate
:
...
@@ -951,7 +945,7 @@ class Connection(ExportImport, object):
...
@@ -951,7 +945,7 @@ class Connection(ExportImport, object):
c
.
_storage
.
release
()
c
.
_storage
.
release
()
c
.
_storage
=
c
.
_normal_storage
=
None
c
.
_storage
=
c
.
_normal_storage
=
None
c
.
_cache
=
PickleCache
(
self
,
0
,
0
)
c
.
_cache
=
PickleCache
(
self
,
0
,
0
)
c
.
transaction_manager
=
None
c
.
close
(
False
)
##########################################################################
##########################################################################
# Python protocol
# Python protocol
...
...
src/ZODB/DB.py
View file @
87b26549
...
@@ -24,7 +24,7 @@ from . import utils
...
@@ -24,7 +24,7 @@ from . import utils
from
ZODB.broken
import
find_global
from
ZODB.broken
import
find_global
from
ZODB.utils
import
z64
from
ZODB.utils
import
z64
from
ZODB.Connection
import
Connection
,
TransactionMetaData
from
ZODB.Connection
import
Connection
,
TransactionMetaData
,
noop
from
ZODB._compat
import
Pickler
,
_protocol
,
BytesIO
from
ZODB._compat
import
Pickler
,
_protocol
,
BytesIO
import
ZODB.serialize
import
ZODB.serialize
...
@@ -646,15 +646,17 @@ class DB(object):
...
@@ -646,15 +646,17 @@ class DB(object):
is closed, so they stop behaving usefully. Perhaps close()
is closed, so they stop behaving usefully. Perhaps close()
should also close all the Connections.
should also close all the Connections.
"""
"""
noop
=
lambda
*
a
:
None
self
.
close
=
noop
self
.
close
=
noop
@
self
.
_connectionMap
@
self
.
_connectionMap
def
_
(
c
):
def
_
(
conn
):
if
c
.
transaction_manager
is
not
None
:
if
conn
.
transaction_manager
is
not
None
:
c
.
transaction_manager
.
abort
()
for
c
in
six
.
itervalues
(
conn
.
connections
):
c
.
afterCompletion
=
c
.
newTransaction
=
c
.
close
=
noop
# Prevent connections from implicitly starting new
c
.
_release_resources
()
# transactions.
c
.
explicit_transactions
=
True
conn
.
transaction_manager
.
abort
()
conn
.
_release_resources
()
self
.
_mvcc_storage
.
close
()
self
.
_mvcc_storage
.
close
()
del
self
.
storage
del
self
.
storage
...
...
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