Clean up watchdog threads
This shouldn't impact real servers, as those processes were about to wrap up anyway. It *can* cause some confusing behaviors in tests, though. Change-Id: Ifd8a64efcd3fc983596ba7cd9fe28eb9663c93d6
This commit is contained in:
parent
761d919677
commit
38d0b3fabc
@ -4853,6 +4853,14 @@ class Watchdog(object):
|
||||
if self._run_gth is None:
|
||||
self._run_gth = eventlet.spawn(self.run)
|
||||
|
||||
def kill(self):
|
||||
"""
|
||||
Stop the watchdog greenthread.
|
||||
"""
|
||||
if self._run_gth is not None:
|
||||
self._run_gth.kill()
|
||||
self._run_gth = None
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
self._run()
|
||||
|
@ -460,7 +460,10 @@ def run_server(conf, logger, sock, global_conf=None, ready_callback=None,
|
||||
except socket.error as err:
|
||||
if err.errno != errno.EINVAL:
|
||||
raise
|
||||
pool.waitall()
|
||||
finally:
|
||||
pool.waitall()
|
||||
if hasattr(app._pipeline_final_app, 'watchdog'):
|
||||
app._pipeline_final_app.watchdog.kill()
|
||||
|
||||
|
||||
class StrategyBase(object):
|
||||
|
@ -634,6 +634,7 @@ class TestWSGI(unittest.TestCase, ConfigAssertMixin):
|
||||
server_sock, server_app, server_logger = args
|
||||
self.assertEqual(sock, server_sock)
|
||||
self.assertIsInstance(server_app, swift.proxy.server.Application)
|
||||
self.assertIsNone(server_app.watchdog._run_gth)
|
||||
self.assertEqual(20, server_app.client_timeout)
|
||||
self.assertIsInstance(server_logger, wsgi.NullLogger)
|
||||
self.assertTrue('custom_pool' in kwargs)
|
||||
|
@ -335,6 +335,10 @@ def setup_servers(the_object_server=object_server, extra_conf=None):
|
||||
def teardown_servers(context):
|
||||
for server in context["test_coros"]:
|
||||
server.kill()
|
||||
# We didn't start the proxy w/ run_server, so we have to kill the
|
||||
# watchdog ourselves
|
||||
context["test_servers"][0].watchdog.kill()
|
||||
assert context["test_servers"][0].watchdog._run_gth is None
|
||||
rmtree(os.path.dirname(context["testdir"]))
|
||||
utils.logs.SysLogHandler = context["orig_SysLogHandler"]
|
||||
storage_policy._POLICIES = context["orig_POLICIES"]
|
||||
|
Loading…
Reference in New Issue
Block a user