Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
1248b5dd
Commit
1248b5dd
authored
Mar 07, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add IllegalStateError calls to prevent assertions from failing.
XXX Should the manager duplicate these checks?
parent
d35cc16d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
src/transaction/txn.py
src/transaction/txn.py
+19
-7
No files found.
src/transaction/txn.py
View file @
1248b5dd
...
...
@@ -3,13 +3,20 @@
__metaclass__
=
type
from
transaction.interfaces
import
ITransaction
,
TransactionError
from
transaction.interfaces
import
*
from
threading
import
Lock
class
Set
(
dict
):
try
:
from
sets
import
Set
except
ImportError
:
def
add
(
self
,
k
):
self
[
k
]
=
1
class
Set
(
dict
):
def
add
(
self
,
k
):
self
[
k
]
=
1
def
remove
(
self
,
k
):
del
self
[
k
]
class
Status
:
...
...
@@ -50,24 +57,29 @@ class Transaction:
def
commit
(
self
):
"""Commit a transaction."""
assert
self
.
_manager
is
not
None
if
self
.
_status
!=
Status
.
ACTIVE
:
raise
IllegalStateError
(
"commit"
,
self
.
_status
)
self
.
_manager
.
commit
(
self
)
def
abort
(
self
):
"""Rollback to initial state."""
assert
self
.
_manager
is
not
None
if
self
.
_status
not
in
(
Status
.
ACTIVE
,
Status
.
PREPARED
,
Status
.
FAILED
):
raise
IllegalStateError
(
"abort"
,
self
.
_status
)
self
.
_manager
.
abort
(
self
)
def
savepoint
(
self
):
"""Save current progress and return a savepoint."""
assert
self
.
_manager
is
not
None
if
self
.
_status
!=
Status
.
ACTIVE
:
raise
IllegalStateError
(
"create savepoint"
,
self
.
_status
)
return
self
.
_manager
.
savepoint
(
self
)
def
join
(
self
,
resource
):
"""resource is participating in the transaction."""
assert
self
.
_manager
is
not
None
if
self
.
_status
!=
Status
.
ACTIVE
:
raise
TransactionError
(
"Can't join transaction. Status=%s"
%
self
.
_status
)
raise
IllegalStateError
(
"join"
,
self
.
_status
)
self
.
_resources
.
add
(
resource
)
def
status
(
self
):
...
...
@@ -78,7 +90,7 @@ class Transaction:
self
.
_lock
.
acquire
()
try
:
if
self
.
_status
==
Status
.
SUSPENDED
:
raise
TransactionError
(
"Already suspended"
)
raise
IllegalStateError
(
"suspend"
,
self
.
_status
)
self
.
_manager
.
suspend
(
self
)
self
.
_suspend
=
self
.
_status
self
.
_status
=
Status
.
SUSPENDED
...
...
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