Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
2da5a3de
Commit
2da5a3de
authored
Feb 09, 2012
by
Jelte Jansen
Browse files
[640] fix race condition in stats test
parent
f328341c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/stats/tests/b10-stats_test.py
View file @
2da5a3de
...
@@ -205,9 +205,12 @@ class TestStats(unittest.TestCase):
...
@@ -205,9 +205,12 @@ class TestStats(unittest.TestCase):
# Override moduleCCSession so we can check if send_stopping is called
# Override moduleCCSession so we can check if send_stopping is called
self
.
stats
.
mccs
=
MockModuleCCSession
()
self
.
stats
.
mccs
=
MockModuleCCSession
()
self
.
assertEqual
(
send_shutdown
(
"Stats"
),
(
0
,
None
))
self
.
assertEqual
(
send_shutdown
(
"Stats"
),
(
0
,
None
))
self
.
assertTrue
(
self
.
stats
.
mccs
.
stopped
)
self
.
assertFalse
(
self
.
stats
.
running
)
self
.
assertFalse
(
self
.
stats
.
running
)
self
.
stats_server
.
shutdown
()
# Call server.shutdown with argument True so the thread.join() call
# blocks and we are sure the main loop has finished (and set
# mccs.stopped)
self
.
stats_server
.
shutdown
(
True
)
self
.
assertTrue
(
self
.
stats
.
mccs
.
stopped
)
# start with err
# start with err
self
.
stats
=
stats
.
Stats
()
self
.
stats
=
stats
.
Stats
()
...
...
src/bin/stats/tests/test_utils.py
View file @
2da5a3de
...
@@ -72,9 +72,19 @@ class ThreadingServerManager:
...
@@ -72,9 +72,19 @@ class ThreadingServerManager:
self
.
server
.
_started
.
wait
()
self
.
server
.
_started
.
wait
()
self
.
server
.
_started
.
clear
()
self
.
server
.
_started
.
clear
()
def
shutdown
(
self
):
def
shutdown
(
self
,
blocking
=
False
):
"""Shut down the server by calling its own shutdown() method.
Then wait for its thread to finish. If blocking is True,
the thread.join() blocks until the thread finishes. If not,
it uses a zero timeout. The latter is necessary in a number
of existing tests. We should redo this part (we should not
even need threads in most, if not all, of these threads, see
ticket #1668)"""
self
.
server
.
shutdown
()
self
.
server
.
shutdown
()
self
.
server
.
_thread
.
join
(
0
)
# timeout is 0
if
blocking
:
self
.
server
.
_thread
.
join
()
else
:
self
.
server
.
_thread
.
join
(
0
)
# timeout is 0
def
do_nothing
(
*
args
,
**
kwargs
):
pass
def
do_nothing
(
*
args
,
**
kwargs
):
pass
...
...
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