mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
Fix TeePopen.terminate by moving send_signal there
This commit is contained in:
parent
df3e4cbfe6
commit
62f2eda0f1
@ -43,25 +43,24 @@ class TeePopen:
|
||||
self.process.pid,
|
||||
self.timeout,
|
||||
)
|
||||
self.send_signal(signal.SIGTERM)
|
||||
self.timeout_exceeded = True
|
||||
self.terminate()
|
||||
|
||||
def terminate(self) -> None:
|
||||
def terminate(self, wait_before_kill: int = 100) -> None:
|
||||
time_wait = 0
|
||||
time_sleep = 5
|
||||
self.terminated_by_sigterm = True
|
||||
while self.process.poll() is None and time_wait < 100:
|
||||
print("wait...")
|
||||
wait = 5
|
||||
sleep(wait)
|
||||
time_wait += wait
|
||||
self.send_signal(signal.SIGTERM)
|
||||
while self.process.poll() is None and time_wait < wait_before_kill:
|
||||
logging.warning("Wait the process %s to terminate", self.process.pid)
|
||||
sleep(time_sleep)
|
||||
time_wait += time_sleep
|
||||
|
||||
self.terminated_by_sigkill = True
|
||||
while self.process.poll() is None:
|
||||
logging.error(
|
||||
"Process is still running. Send SIGKILL",
|
||||
)
|
||||
logging.error("Process is still running. Send SIGKILL")
|
||||
self.send_signal(signal.SIGKILL)
|
||||
self.terminated_by_sigkill = True
|
||||
sleep(5)
|
||||
sleep(time_sleep)
|
||||
|
||||
def __enter__(self) -> "TeePopen":
|
||||
self.process = Popen(
|
||||
|
Loading…
Reference in New Issue
Block a user