mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Merge pull request #58213 from azat/tests/processes-cleanup-v2
Fix leftover processes/hangs in tests (resubmit)
This commit is contained in:
commit
35e27ab1a3
@ -1031,7 +1031,24 @@ class TestCase:
|
||||
if proc:
|
||||
if proc.returncode is None:
|
||||
try:
|
||||
proc.kill()
|
||||
pgid = os.getpgid(proc.pid)
|
||||
# NOTE: this still may leave some processes, that had been
|
||||
# created by timeout(1), since it also creates new process
|
||||
# group. But this should not be a problem with default
|
||||
# options, since the default time for each test is 10min,
|
||||
# and this is way more bigger then the timeout for each
|
||||
# timeout(1) invocation.
|
||||
#
|
||||
# But as a workaround we are sending SIGTERM first, and
|
||||
# only after SIGKILL, that way timeout(1) will have an
|
||||
# ability to terminate childrens (though not always since
|
||||
# signals are asynchronous).
|
||||
os.killpg(pgid, signal.SIGTERM)
|
||||
# This may not be enough, but this is at least something
|
||||
# (and anyway it is OK to spend 0.1 second more in case of
|
||||
# test timeout).
|
||||
sleep(0.1)
|
||||
os.killpg(pgid, signal.SIGKILL)
|
||||
except OSError as e:
|
||||
if e.errno != ESRCH:
|
||||
raise
|
||||
@ -1307,7 +1324,7 @@ class TestCase:
|
||||
|
||||
command = pattern.format(**params)
|
||||
|
||||
proc = Popen(command, shell=True, env=os.environ)
|
||||
proc = Popen(command, shell=True, env=os.environ, start_new_session=True)
|
||||
|
||||
while (
|
||||
datetime.now() - start_time
|
||||
|
Loading…
Reference in New Issue
Block a user