From 13f7aede61fb62f2cad81bf171edbddf430fe117 Mon Sep 17 00:00:00 2001 From: Julien Tachoires Date: Mon, 11 Mar 2019 10:35:36 +0100 Subject: [PATCH] Wait for callback end if it could not be killed (#985) that could happen if the script is running under a sudo --- patroni/callback_executor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/patroni/callback_executor.py b/patroni/callback_executor.py index 718af67a..4764cae1 100644 --- a/patroni/callback_executor.py +++ b/patroni/callback_executor.py @@ -19,8 +19,13 @@ class CallbackExecutor(Thread): def call(self, cmd): with self._lock: if self._process and self._process.poll() is None: - self._process.kill() - logger.warning('Killed the old callback process because it was still running: %s', self._cmd) + try: + self._process.kill() + logger.warning('Killed the old callback process because it was still running: %s', self._cmd) + except OSError: + logger.exception('Failed to kill the old callback') + logger.warning('Wait until callback end') + self._process.wait() self._cmd = cmd self._callback_event.set()