Skip to content

Commit

Permalink
WIP: review Connection/DB closure
Browse files Browse the repository at this point in the history
  • Loading branch information
jmuchemb committed Sep 21, 2017
1 parent 0442e15 commit 46874e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
8 changes: 3 additions & 5 deletions src/ZODB/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ def close(self, primary=True):
raise ConnectionStateError("Cannot close a connection joined to "
"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.
if self.__onCloseCallbacks is not None:
Expand Down Expand Up @@ -924,8 +923,7 @@ def open(self, transaction_manager=None, delegate=True):

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:
# delegate open to secondary connections
Expand All @@ -951,7 +949,7 @@ def _release_resources(self):
c._storage.release()
c._storage = c._normal_storage = None
c._cache = PickleCache(self, 0, 0)
c.transaction_manager = None
c.close(False)

##########################################################################
# Python protocol
Expand Down
14 changes: 7 additions & 7 deletions src/ZODB/DB.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from ZODB.broken import find_global
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
import ZODB.serialize

Expand Down Expand Up @@ -646,15 +646,15 @@ def close(self):
is closed, so they stop behaving usefully. Perhaps close()
should also close all the Connections.
"""
noop = lambda *a: None
self.close = noop

@self._connectionMap
def _(c):
if c.transaction_manager is not None:
c.transaction_manager.abort()
c.afterCompletion = c.newTransaction = c.close = noop
c._release_resources()
def _(conn):
if conn.transaction_manager is not None:
for c in six.itervalues(conn.connections):
c.explicit_transactions = True
conn.transaction_manager.abort()
conn._release_resources()

self._mvcc_storage.close()
del self.storage
Expand Down

0 comments on commit 46874e0

Please sign in to comment.