diff options
author | iaz1607 <iaz1607@yandex-team.ru> | 2022-02-10 16:45:37 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:37 +0300 |
commit | 94e51c602b555459333b3c6ae92476c424c930bc (patch) | |
tree | b2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /library/python/testing/recipe | |
parent | e5437feb4ac2d2dc044e1090b9312dde5ef197e0 (diff) | |
download | ydb-94e51c602b555459333b3c6ae92476c424c930bc.tar.gz |
Restoring authorship annotation for <iaz1607@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python/testing/recipe')
-rw-r--r-- | library/python/testing/recipe/ports.py | 66 | ||||
-rw-r--r-- | library/python/testing/recipe/ya.make | 10 |
2 files changed, 38 insertions, 38 deletions
diff --git a/library/python/testing/recipe/ports.py b/library/python/testing/recipe/ports.py index 1344a58ac9..9f7de1e767 100644 --- a/library/python/testing/recipe/ports.py +++ b/library/python/testing/recipe/ports.py @@ -1,33 +1,33 @@ -import os -import sys -import subprocess -import time - -from yatest.common.network import PortManager - - -def __get_port_range(): - port_count = int(sys.argv[1]) - pid_filename = sys.argv[2] - port_manager = PortManager() - start_port = port_manager.get_port_range(None, port_count) - sys.stderr.write(str(start_port) + "\n") - with open(pid_filename, 'w') as afile: - afile.write(str(os.getpid())) - while 1: - time.sleep(1) - - -def get_port_range(port_count=1, pid_filename="recipe_port.pid"): - env = os.environ.copy() - env["Y_PYTHON_ENTRY_POINT"] = "library.python.testing.recipe.ports:__get_port_range" - res = subprocess.Popen([sys.argv[0], str(port_count), pid_filename], env=env, cwd=os.getcwd(), stderr=subprocess.PIPE) - while not os.path.exists(pid_filename): - time.sleep(0.01) - port_start = int(res.stderr.readline()) - return port_start - - -def release_port_range(pid_filename="recipe_port.pid"): - with open(pid_filename, 'r') as afile: - os.kill(int(afile.read()), 9) +import os +import sys +import subprocess +import time + +from yatest.common.network import PortManager + + +def __get_port_range(): + port_count = int(sys.argv[1]) + pid_filename = sys.argv[2] + port_manager = PortManager() + start_port = port_manager.get_port_range(None, port_count) + sys.stderr.write(str(start_port) + "\n") + with open(pid_filename, 'w') as afile: + afile.write(str(os.getpid())) + while 1: + time.sleep(1) + + +def get_port_range(port_count=1, pid_filename="recipe_port.pid"): + env = os.environ.copy() + env["Y_PYTHON_ENTRY_POINT"] = "library.python.testing.recipe.ports:__get_port_range" + res = subprocess.Popen([sys.argv[0], str(port_count), pid_filename], env=env, cwd=os.getcwd(), stderr=subprocess.PIPE) + while not os.path.exists(pid_filename): + time.sleep(0.01) + port_start = int(res.stderr.readline()) + return port_start + + +def release_port_range(pid_filename="recipe_port.pid"): + with open(pid_filename, 'r') as afile: + os.kill(int(afile.read()), 9) diff --git a/library/python/testing/recipe/ya.make b/library/python/testing/recipe/ya.make index 4698546e42..dd323aa245 100644 --- a/library/python/testing/recipe/ya.make +++ b/library/python/testing/recipe/ya.make @@ -5,14 +5,14 @@ OWNER( PY23_LIBRARY() -PY_SRCS( - __init__.py - ports.py -) +PY_SRCS( + __init__.py + ports.py +) PEERDIR( contrib/python/ipdb - library/python/testing/yatest_common + library/python/testing/yatest_common library/python/testing/yatest_lib ) |