Rest api thread can raise an exception during shutdown (#711)

catch it and report
This commit is contained in:
Alexander Kukushkin
2018-06-14 13:17:50 +02:00
committed by GitHub
parent 41e5f58f2b
commit 8a3b78ca7b
2 changed files with 8 additions and 1 deletions

View File

@@ -129,7 +129,10 @@ class Patroni(object):
signal.signal(signal.SIGTERM, self.sigterm_handler)
def shutdown(self):
self.api.shutdown()
try:
self.api.shutdown()
except Exception:
logger.exception('Exception during RestApi.shutdown')
self.ha.shutdown()

View File

@@ -151,3 +151,7 @@ class TestPatroni(unittest.TestCase):
self.assertTrue(self.p.nosync)
self.p.tags['nosync'] = None
self.assertFalse(self.p.nosync)
def test_shutdown(self):
self.p.api.shutdown = Mock(side_effect=Exception)
self.p.shutdown()