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
2bb9e897
Commit
2bb9e897
authored
Mar 31, 2016
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix AttributeError: 'ZEOServer' object has no attribute 'server'.
parent
ac9692f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
1 deletion
+78
-1
CHANGES.rst
CHANGES.rst
+3
-0
src/ZEO/runzeo.py
src/ZEO/runzeo.py
+6
-1
src/ZEO/tests/testZEOServer.py
src/ZEO/tests/testZEOServer.py
+69
-0
No files found.
CHANGES.rst
View file @
2bb9e897
...
...
@@ -6,6 +6,9 @@ Changelog
- Drop support for Python 2.6 and 3.2.
- Fix AttributeError: 'ZEOServer' object has no attribute 'server' when
StorageServer creation fails.
4.2.0b1 (2015-06-05)
--------------------
...
...
src/ZEO/runzeo.py
View file @
2bb9e897
...
...
@@ -150,6 +150,7 @@ class ZEOServer:
def
__init__
(
self
,
options
):
self
.
options
=
options
self
.
server
=
None
def
main
(
self
):
self
.
setup_default_logging
()
...
...
@@ -162,7 +163,7 @@ class ZEOServer:
self
.
create_server
()
self
.
loop_forever
()
finally
:
self
.
server
.
close
()
self
.
close_server
()
self
.
clear_socket
()
self
.
remove_pidfile
()
...
...
@@ -262,6 +263,10 @@ class ZEOServer:
else
:
self
.
server
.
loop
()
def
close_server
(
self
):
if
self
.
server
is
not
None
:
self
.
server
.
close
()
def
handle_sigterm
(
self
):
log
(
"terminated by SIGTERM"
)
sys
.
exit
(
0
)
...
...
src/ZEO/tests/testZEOServer.py
View file @
2bb9e897
...
...
@@ -70,7 +70,76 @@ class AttributeErrorTests(unittest.TestCase):
self
.
assertRaises
(
RuntimeError
,
zeo
.
main
)
class
CloseServerTests
(
unittest
.
TestCase
):
def
testCallSequence
(
self
):
# The close_server hook is called after loop_forever
# has returned
zeo
=
TestZEOServer
()
zeo
.
main
()
self
.
assertEqual
(
zeo
.
called
,
[
"setup_default_logging"
,
"check_socket"
,
"clear_socket"
,
"make_pidfile"
,
"open_storages"
,
"setup_signals"
,
"create_server"
,
"loop_forever"
,
"close_server"
,
# New
"clear_socket"
,
"remove_pidfile"
,
])
# The default implementation closes the storage server
self
.
assertEqual
(
hasattr
(
zeo
,
"server"
),
True
)
self
.
assertEqual
(
zeo
.
server
.
called
,
[
"close"
])
def
testFailLoopForever
(
self
):
# The close_server hook is called if loop_forever exits
# with an exception
zeo
=
TestZEOServer
(
fail_loop_forever
=
True
)
self
.
assertRaises
(
RuntimeError
,
zeo
.
main
)
self
.
assertEqual
(
zeo
.
called
,
[
"setup_default_logging"
,
"check_socket"
,
"clear_socket"
,
"make_pidfile"
,
"open_storages"
,
"setup_signals"
,
"create_server"
,
"loop_forever"
,
"close_server"
,
"clear_socket"
,
"remove_pidfile"
,
])
# The storage server has been closed
self
.
assertEqual
(
hasattr
(
zeo
,
"server"
),
True
)
self
.
assertEqual
(
zeo
.
server
.
called
,
[
"close"
])
def
testFailCreateServer
(
self
):
# The close_server hook is called if create_server exits
# with an exception
zeo
=
TestZEOServer
(
fail_create_server
=
True
)
self
.
assertRaises
(
RuntimeError
,
zeo
.
main
)
self
.
assertEqual
(
zeo
.
called
,
[
"setup_default_logging"
,
"check_socket"
,
"clear_socket"
,
"make_pidfile"
,
"open_storages"
,
"setup_signals"
,
"create_server"
,
"close_server"
,
"clear_socket"
,
"remove_pidfile"
,
])
# The server attribute is present but None
self
.
assertEqual
(
hasattr
(
zeo
,
"server"
),
True
)
self
.
assertEqual
(
zeo
.
server
,
None
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
AttributeErrorTests
))
suite
.
addTest
(
unittest
.
makeSuite
(
CloseServerTests
))
return
suite
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