Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Iliya Manolov
neoppod
Commits
30ccff6e
Commit
30ccff6e
authored
Aug 21, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simple: exit automatically when all nodes are dead
parent
d36093ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
38 deletions
+28
-38
neo/scripts/simple.py
neo/scripts/simple.py
+2
-2
neo/tests/functional/__init__.py
neo/tests/functional/__init__.py
+26
-36
No files found.
neo/scripts/simple.py
View file @
30ccff6e
...
@@ -49,9 +49,9 @@ def main():
...
@@ -49,9 +49,9 @@ def main():
try
:
try
:
cluster
.
run
()
cluster
.
run
()
logging
.
info
(
"Cluster running ..."
)
logging
.
info
(
"Cluster running ..."
)
signal
.
pause
()
cluster
.
waitAll
()
finally
:
finally
:
cluster
.
stop
()
cluster
.
stop
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
sys
.
exit
(
main
()
)
main
(
)
neo/tests/functional/__init__.py
View file @
30ccff6e
...
@@ -116,32 +116,6 @@ class PortAllocator(object):
...
@@ -116,32 +116,6 @@ class PortAllocator(object):
__del__
=
reset
__del__
=
reset
class
ChildException
(
KeyboardInterrupt
):
"""Wrap any exception into an exception that is not catched by TestCase.run
The exception is not wrapped and re-raised immediately if there is no need
to wrap.
"""
def
__init__
(
self
,
type
,
value
,
tb
):
code
=
unittest
.
TestCase
.
run
.
im_func
.
func_code
f
=
tb
.
tb_frame
while
f
is
not
None
:
if
f
.
f_code
is
code
:
break
f
=
f
.
f_back
else
:
raise
type
,
value
,
tb
KeyboardInterrupt
.
__init__
(
self
,
type
,
value
,
tb
)
def
__call__
(
self
):
"""Re-raise wrapped exception"""
type
,
value
,
tb
=
self
.
args
if
type
is
KeyboardInterrupt
:
sys
.
exit
(
1
)
raise
type
,
value
,
tb
class
NEOProcess
(
object
):
class
NEOProcess
(
object
):
pid
=
0
pid
=
0
...
@@ -171,8 +145,6 @@ class NEOProcess(object):
...
@@ -171,8 +145,6 @@ class NEOProcess(object):
self
.
pid
=
os
.
fork
()
self
.
pid
=
os
.
fork
()
if
self
.
pid
==
0
:
if
self
.
pid
==
0
:
# Child
# Child
# prevent child from killing anything
del
self
.
__class__
.
__del__
try
:
try
:
# release SQLite debug log
# release SQLite debug log
logging
.
setup
()
logging
.
setup
()
...
@@ -181,9 +153,25 @@ class NEOProcess(object):
...
@@ -181,9 +153,25 @@ class NEOProcess(object):
allocator
.
reset
()
allocator
.
reset
()
sys
.
argv
=
[
command
]
+
args
sys
.
argv
=
[
command
]
+
args
getattr
(
neo
.
scripts
,
command
).
main
()
getattr
(
neo
.
scripts
,
command
).
main
()
sys
.
exit
()
status
=
0
except
SystemExit
,
e
:
status
=
e
.
code
if
status
is
None
:
status
=
0
except
KeyboardInterrupt
:
status
=
1
except
:
except
:
raise
ChildException
(
*
sys
.
exc_info
())
status
=
-
1
traceback
.
print_exc
()
finally
:
# prevent child from killing anything (cf __del__), or
# running any other cleanup code normally done by the parent
try
:
os
.
_exit
(
status
)
except
:
print
>>
sys
.
stderr
,
status
finally
:
os
.
_exit
(
1
)
logging
.
info
(
'pid %u: %s %s'
,
logging
.
info
(
'pid %u: %s %s'
,
self
.
pid
,
command
,
' '
.
join
(
map
(
repr
,
args
)))
self
.
pid
,
command
,
' '
.
join
(
map
(
repr
,
args
)))
...
@@ -411,6 +399,14 @@ class NEOCluster(object):
...
@@ -411,6 +399,14 @@ class NEOCluster(object):
if
error_list
:
if
error_list
:
raise
NodeProcessError
(
'
\
n
'
.
join
(
error_list
))
raise
NodeProcessError
(
'
\
n
'
.
join
(
error_list
))
def
waitAll
(
self
):
for
process_list
in
self
.
process_dict
.
itervalues
():
for
process
in
process_list
:
try
:
process
.
wait
()
except
(
AlreadyStopped
,
NodeProcessError
):
pass
def
getNEOCTL
(
self
):
def
getNEOCTL
(
self
):
return
self
.
neoctl
return
self
.
neoctl
...
@@ -663,12 +659,6 @@ class NEOFunctionalTest(NeoTestBase):
...
@@ -663,12 +659,6 @@ class NEOFunctionalTest(NeoTestBase):
os
.
makedirs
(
temp_dir
)
os
.
makedirs
(
temp_dir
)
return
temp_dir
return
temp_dir
def
run
(
self
,
*
args
,
**
kw
):
try
:
return
super
(
NEOFunctionalTest
,
self
).
run
(
*
args
,
**
kw
)
except
ChildException
,
e
:
e
()
def
runWithTimeout
(
self
,
timeout
,
method
,
args
=
(),
kwargs
=
None
):
def
runWithTimeout
(
self
,
timeout
,
method
,
args
=
(),
kwargs
=
None
):
if
kwargs
is
None
:
if
kwargs
is
None
:
kwargs
=
{}
kwargs
=
{}
...
...
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