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
nexedi
ZODB
Commits
c41bc70d
Commit
c41bc70d
authored
Aug 14, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some comments and assertions about expected used of condition variable.
parent
16b081c8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
src/ZEO/ClientStorage.py
src/ZEO/ClientStorage.py
+17
-12
No files found.
src/ZEO/ClientStorage.py
View file @
c41bc70d
...
@@ -12,8 +12,9 @@
...
@@ -12,8 +12,9 @@
#
#
##############################################################################
##############################################################################
"""Network ZODB storage client
"""Network ZODB storage client
$Id: ClientStorage.py,v 1.43 2002/08/14 16:22:23 jeremy Exp $
"""
"""
__version__
=
'$Revision: 1.42 $'
[
11
:
-
2
]
import
cPickle
import
cPickle
import
os
import
os
...
@@ -62,6 +63,13 @@ class DisconnectedServerStub:
...
@@ -62,6 +63,13 @@ class DisconnectedServerStub:
disconnected_stub
=
DisconnectedServerStub
()
disconnected_stub
=
DisconnectedServerStub
()
import
thread
def
check_thread_id
(
txn
):
if
txn
.
_id
is
None
:
# We can't tell what thread created this
return
1
return
txn
.
_id
==
thread
.
get_ident
()
class
ClientStorage
:
class
ClientStorage
:
def
__init__
(
self
,
addr
,
storage
=
'1'
,
cache_size
=
20000000
,
def
__init__
(
self
,
addr
,
storage
=
'1'
,
cache_size
=
20000000
,
...
@@ -113,9 +121,12 @@ class ClientStorage:
...
@@ -113,9 +121,12 @@ class ClientStorage:
self
.
__name__
=
name
self
.
__name__
=
name
# A ClientStorage only allows one client to commit at a time.
# A ClientStorage only allows one client to commit at a time.
# A client enters the commit state by finding tpc_tid set to
# Mutual exclusion is achieved using tpc_cond(), which
# None and updating it to the new transaction's id. The
# protects _transaction. A thread that wants to assign to
# tpc_tid variable is protected by tpc_cond.
# self._transaction must acquire tpc_cond() first.
# Invariant: If self._transaction is not None, then tpc_cond()
# must be acquired.
self
.
tpc_cond
=
threading
.
Condition
()
self
.
tpc_cond
=
threading
.
Condition
()
self
.
_transaction
=
None
self
.
_transaction
=
None
...
@@ -218,14 +229,6 @@ class ClientStorage:
...
@@ -218,14 +229,6 @@ class ClientStorage:
raise
exc
(
self
.
_transaction
,
trans
)
raise
exc
(
self
.
_transaction
,
trans
)
return
1
return
1
def
_check_tid
(
self
,
tid
,
exc
=
None
):
if
self
.
tpc_tid
!=
tid
:
if
exc
is
None
:
return
0
else
:
raise
exc
(
self
.
tpc_tid
,
tid
)
return
1
def
abortVersion
(
self
,
src
,
transaction
):
def
abortVersion
(
self
,
src
,
transaction
):
if
self
.
_is_read_only
:
if
self
.
_is_read_only
:
raise
POSException
.
ReadOnlyError
()
raise
POSException
.
ReadOnlyError
()
...
@@ -330,6 +333,7 @@ class ClientStorage:
...
@@ -330,6 +333,7 @@ class ClientStorage:
def
tpc_abort
(
self
,
transaction
):
def
tpc_abort
(
self
,
transaction
):
if
transaction
is
not
self
.
_transaction
:
if
transaction
is
not
self
.
_transaction
:
return
return
assert
check_thread_id
(
transaction
)
try
:
try
:
self
.
_server
.
tpc_abort
(
self
.
_serial
)
self
.
_server
.
tpc_abort
(
self
.
_serial
)
self
.
_tbuf
.
clear
()
self
.
_tbuf
.
clear
()
...
@@ -389,6 +393,7 @@ class ClientStorage:
...
@@ -389,6 +393,7 @@ class ClientStorage:
def
tpc_finish
(
self
,
transaction
,
f
=
None
):
def
tpc_finish
(
self
,
transaction
,
f
=
None
):
if
transaction
is
not
self
.
_transaction
:
if
transaction
is
not
self
.
_transaction
:
return
return
assert
check_thread_id
(
transaction
)
try
:
try
:
if
f
is
not
None
:
if
f
is
not
None
:
f
()
f
()
...
...
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