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
7a201718
Commit
7a201718
authored
Aug 27, 2004
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise ConnectionStateError if an attempt to close a connection
is made while the connection has a pending subtransaction.
parent
a1c7a05f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
branches/3.3/NEWS.txt
branches/3.3/NEWS.txt
+14
-0
branches/3.3/src/ZODB/Connection.py
branches/3.3/src/ZODB/Connection.py
+6
-0
branches/3.3/src/ZODB/tests/testConnection.py
branches/3.3/src/ZODB/tests/testConnection.py
+36
-2
No files found.
branches/3.3/NEWS.txt
View file @
7a201718
...
...
@@ -2,6 +2,20 @@ What's new in ZODB3 3.3 ?
=========================
Release date: DD-MMM-YYYY
Connection
----------
ZODB intends to raise ConnnectionStateError if an attempt is made to
close a connection while modifications are pending (the connection is
involved in a transaction that hasn't been abort()'ed or commit()'ed).
It was missing the case where the only pending modifications were made
in subtransactions. This has been fixed. If an attempt to close a
connection with pending subtransactions is made now,
ConnnectionStateError: Cannot close a connection with a pending subtransaction
is raised.
transaction
-----------
...
...
branches/3.3/src/ZODB/Connection.py
View file @
7a201718
...
...
@@ -540,6 +540,12 @@ class Connection(ExportImport, object):
raise
ConnectionStateError
(
"Cannot close a connection joined to "
"a transaction"
)
if
self
.
_tmp
is
not
None
:
# There are no direct modifications pending, but a subtransaction
# is pending.
raise
ConnectionStateError
(
"Cannot close a connection with a "
"pending subtransaction"
)
if
self
.
_cache
is
not
None
:
self
.
_cache
.
incrgc
()
# This is a good time to do some GC
...
...
branches/3.3/src/ZODB/tests/testConnection.py
View file @
7a201718
...
...
@@ -264,7 +264,7 @@ class UserMethodTests(unittest.TestCase):
>>> transaction.commit()
>>> cn.close()
Opening, making a change,
committing,
and aborting is fine.
Opening, making a change, and aborting is fine.
>>> cn = db.open()
>>> cn.root()['a'] = 1
>>> transaction.abort()
...
...
@@ -272,7 +272,7 @@ class UserMethodTests(unittest.TestCase):
But trying to close with a change pending complains.
>>> cn = db.open()
>>> cn.root()['a'] = 1
>>> cn.root()['a'] = 1
0
>>> cn.close()
Traceback (most recent call last):
...
...
...
@@ -281,7 +281,41 @@ class UserMethodTests(unittest.TestCase):
This leaves the connection as it was, so we can still commit
the change.
>>> transaction.commit()
>>> cn2 = db.open()
>>> cn2.root()['a']
10
>>> cn.close(); cn2.close()
Bug: We weren't catching the case where the only changes pending
were in a subtransaction.
>>> cn = db.open()
>>> cn.root()['a'] = 100
>>> transaction.commit(True)
>>> cn.close() # this was succeeding
Traceback (most recent call last):
...
ConnectionStateError: Cannot close a connection with a pending subtransaction
Again this leaves the connection as it was.
>>> transaction.commit()
>>> cn2 = db.open()
>>> cn2.root()['a']
100
>>> cn.close(); cn2.close()
Make sure we can still close a connection after aborting a pending
subtransaction.
>>> cn = db.open()
>>> cn.root()['a'] = 1000
>>> transaction.commit(True)
>>> cn.root()['a']
1000
>>> transaction.abort()
>>> cn.root()['a']
100
>>> cn.close()
>>> db.close()
"""
def
test_onCloseCallbacks
(
self
):
...
...
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