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
e3883512
Commit
e3883512
authored
Dec 22, 2009
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed close to use the asyncore thread to try to avoid a race and
breaking the client loop.
parent
a245abee
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
2 deletions
+45
-2
src/ZEO/ClientStorage.py
src/ZEO/ClientStorage.py
+14
-2
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+31
-0
No files found.
src/ZEO/ClientStorage.py
View file @
e3883512
...
@@ -442,11 +442,20 @@ class ClientStorage(object):
...
@@ -442,11 +442,20 @@ class ClientStorage(object):
logger
.
info
(
"%s Waiting for cache verification to finish"
,
logger
.
info
(
"%s Waiting for cache verification to finish"
,
self
.
__name__
)
self
.
__name__
)
def
close
(
self
):
def
close
(
self
,
kill
=
False
):
"
""Storage API: finalize the storage, releasing external resources.""
"
"
Storage API: finalize the storage, releasing external resources.
"
if
self
.
_rpc_mgr
is
not
None
:
if
self
.
_rpc_mgr
is
not
None
:
self
.
_rpc_mgr
.
close
()
self
.
_rpc_mgr
.
close
()
self
.
_rpc_mgr
=
None
self
.
_rpc_mgr
=
None
if
(
self
.
_connection
is
not
None
)
and
not
kill
:
event
=
threading
.
Event
()
self
.
_connection
.
trigger
.
pull_trigger
(
lambda
:
self
.
_close
(
event
))
event
.
wait
(
9
)
else
:
self
.
_close
()
def
_close
(
self
,
event
=
None
):
if
self
.
_connection
is
not
None
:
if
self
.
_connection
is
not
None
:
self
.
_connection
.
register_object
(
None
)
# Don't call me!
self
.
_connection
.
register_object
(
None
)
# Don't call me!
self
.
_connection
.
close
()
self
.
_connection
.
close
()
...
@@ -462,6 +471,9 @@ class ClientStorage(object):
...
@@ -462,6 +471,9 @@ class ClientStorage(object):
if
self
.
_check_blob_size_thread
is
not
None
:
if
self
.
_check_blob_size_thread
is
not
None
:
self
.
_check_blob_size_thread
.
join
()
self
.
_check_blob_size_thread
.
join
()
if
event
is
not
None
:
event
.
set
()
_check_blob_size_thread
=
None
_check_blob_size_thread
=
None
def
_check_blob_size
(
self
,
bytes
=
None
):
def
_check_blob_size
(
self
,
bytes
=
None
):
if
self
.
_blob_cache_size
is
None
:
if
self
.
_blob_cache_size
is
None
:
...
...
src/ZEO/tests/testZEO.py
View file @
e3883512
...
@@ -951,6 +951,8 @@ def tpc_finish_error():
...
@@ -951,6 +951,8 @@ def tpc_finish_error():
... pass
... pass
... def close(self):
... def close(self):
... print 'connection closed'
... print 'connection closed'
... trigger = property(lambda self: self)
... pull_trigger = lambda self, func: func()
>>> class ConnectionManager:
>>> class ConnectionManager:
... def __init__(self, addr, client, tmin, tmax):
... def __init__(self, addr, client, tmin, tmax):
...
@@ -1228,6 +1230,35 @@ def runzeo_without_configfile():
...
@@ -1228,6 +1230,35 @@ def runzeo_without_configfile():
testing exit immediately
testing exit immediately
"""
"""
def
close_client_storage_w_invalidations
():
r"""
Invalidations could cause errors when closing client storages,
>>> addr, _ = start_server()
>>> writing = threading.Event()
>>> def mad_write_thread():
... global writing
... conn = ZEO.connection(addr)
... writing.set()
... while writing.isSet():
... conn.root.x = 1
... transaction.commit()
... conn.close()
>>> thread = threading.Thread(target=mad_write_thread)
>>> thread.setDaemon(True)
>>> thread.start()
>>> writing.wait()
>>> time.sleep(.01)
>>> for i in range(10):
... conn = ZEO.connection(addr)
... _ = conn._storage.load('\0'*8)
... conn.close()
>>> writing.clear()
>>> thread.join(1)
"""
slow_test_classes
=
[
slow_test_classes
=
[
BlobAdaptedFileStorageTests
,
BlobWritableCacheTests
,
BlobAdaptedFileStorageTests
,
BlobWritableCacheTests
,
DemoStorageTests
,
FileStorageTests
,
MappingStorageTests
,
DemoStorageTests
,
FileStorageTests
,
MappingStorageTests
,
...
...
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