diff options
author | qrort <qrort@yandex-team.com> | 2022-12-02 11:31:25 +0300 |
---|---|---|
committer | qrort <qrort@yandex-team.com> | 2022-12-02 11:31:25 +0300 |
commit | b1f4ffc9c8abff3ba58dc1ec9a9f92d2f0de6806 (patch) | |
tree | 2a23209faf0fea5586a6d4b9cee60d1b318d29fe /library/recipes/common | |
parent | 559174a9144de40d6bb3997ea4073c82289b4974 (diff) | |
download | ydb-b1f4ffc9c8abff3ba58dc1ec9a9f92d2f0de6806.tar.gz |
remove kikimr/driver DEPENDS
Diffstat (limited to 'library/recipes/common')
-rw-r--r-- | library/recipes/common/__init__.py | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/library/recipes/common/__init__.py b/library/recipes/common/__init__.py deleted file mode 100644 index 84308b1327..0000000000 --- a/library/recipes/common/__init__.py +++ /dev/null @@ -1,74 +0,0 @@ -import os.path -import psutil -import socket -import subprocess -import time -import yatest.common - - -def find_free_ports(count): - sockets = [] - ports = [] - - for _ in range(count): - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.bind(('', 0)) - ports.append(sock.getsockname()[1]) - sockets.append(sock) - - for sock in sockets: - sock.close() - return ports - - -def start_daemon(command, environment, is_alive_check, pid_file_name, timeout=60, daemon_name=None): - daemon_name = daemon_name or os.path.basename(command[0]) - stdout_path = yatest.common.output_path('{}.out.log').format(daemon_name) - stderr_path = yatest.common.output_path('{}.err.log').format(daemon_name) - - process = subprocess.Popen( - command, - stdout=open(stdout_path, 'w'), - stderr=open(stderr_path, 'w'), - env=environment) - with open(pid_file_name, 'w') as fout: - fout.write(str(process.pid)) - - for attempts in range(timeout): - result = process.poll() - if result is not None: - raise RuntimeError( - 'Could not launch "{}" with exit code {}\nStdout: {}\nStderr: {}' - .format(daemon_name, result, stdout_path, stderr_path) - ) - - if is_alive_check(): - return - - time.sleep(1) - - raise RuntimeError( - 'Could not launch "{}" for {} seconds\nStdout: {}\nStderr: {}' - .format(daemon_name, timeout, stdout_path, stderr_path) - ) - - -def pid_exists(pid): - try: - if psutil.Process(pid).status() == psutil.STATUS_ZOMBIE: - return False - except psutil.NoSuchProcess: - return False - return True - - -def stop_daemon(pid, signal=15): - pid = int(pid) - if not pid_exists(pid): - return False - - os.kill(pid, signal) - while pid_exists(pid): - time.sleep(1) - - return True |