Guard against double shutdown in client

If we have already performed a shutdown we can prevent exploding when
writing to self.wake_write if we short circuit.

Change-Id: If5352a373d5fa61dd1ee661f4a37976b3447dd9d
This commit is contained in:
Gregory Haynes 2016-01-26 20:14:20 +00:00
parent 5491e93d95
commit c313be6e18
2 changed files with 14 additions and 5 deletions

View File

@ -1105,11 +1105,15 @@ class BaseClientServer(object):
The object may no longer be used after shutdown is called.
"""
self.log.debug("Beginning shutdown")
self._shutdown()
self.log.debug("Beginning cleanup")
self._cleanup()
self.log.debug("Finished shutdown")
if self.running:
self.log.debug("Beginning shutdown")
self._shutdown()
self.log.debug("Beginning cleanup")
self._cleanup()
self.log.debug("Finished shutdown")
else:
self.log.warning("Shutdown called when not currently running. "
"Ignoring.")
def _shutdown(self):
# The first part of the shutdown process where all threads

View File

@ -287,6 +287,11 @@ class TestClient(tests.BaseTestCase):
acl.revokeGrant('manager')
self.assertFalse(acl.canGrant('manager'))
def test_double_shutdown(self):
client = gear.Client()
client.shutdown()
client.shutdown()
def load_tests(loader, in_tests, pattern):
return testscenarios.load_tests_apply_scenarios(loader, in_tests, pattern)