test terminate process

This commit is contained in:
Kseninia Mikhaylova 2024-11-12 09:34:13 +03:00
parent 6048a54b38
commit a690d34d99
4 changed files with 76 additions and 10 deletions

21
app.log
View File

@ -68820,3 +68820,24 @@ Joint 5 - Position: 2.6324369751913186e-19, Velocity: -1.7044130180708233e-30 -
2024-11-12 09:17:10,286 - logger - INFO - Старт одиночного цикла - client_socket.py - 329
2024-11-12 09:17:10,839 - logger - ERROR - Error sending data: [Errno 104] Connection reset by peer - client_socket.py - 110
2024-11-12 09:17:10,889 - logger - ERROR - Error sending data: [Errno 32] Broken pipe - client_socket.py - 110
2024-11-12 09:31:32,606 - logger - INFO - robot_app еще не инициализирован. Метод: get_status - main.py - 100
2024-11-12 09:31:32,606 - logger - INFO - None - robot.py - 52
2024-11-12 09:31:32,606 - logger - INFO - robot_app еще не инициализирован. Метод: get_status - main.py - 100
2024-11-12 09:31:32,606 - logger - INFO - robot_app еще не инициализирован. Метод: get_status - main.py - 100
2024-11-12 09:31:32,606 - logger - INFO - robot_app еще не инициализирован. Метод: get_status - main.py - 100
2024-11-12 09:31:32,607 - logger - INFO - robot_app еще не инициализирован. Метод: get_world_coordinates - main.py - 100
2024-11-12 09:31:32,607 - logger - INFO - robot_app еще не инициализирован. Метод: get_axis_coordinates - main.py - 100
2024-11-12 09:31:32,607 - logger - INFO - robot_app еще не инициализирован. Метод: get_command_count - main.py - 100
2024-11-12 09:31:33,636 - logger - INFO - Connect to 0 by SHARED_MEMORY - client_socket.py - 130
2024-11-12 09:33:38,800 - logger - INFO - robot_app еще не инициализирован. Метод: get_status - main.py - 100
2024-11-12 09:33:38,800 - logger - INFO - None - robot.py - 52
2024-11-12 09:33:38,800 - logger - INFO - robot_app еще не инициализирован. Метод: get_status - main.py - 100
2024-11-12 09:33:38,800 - logger - INFO - robot_app еще не инициализирован. Метод: get_status - main.py - 100
2024-11-12 09:33:38,800 - logger - INFO - robot_app еще не инициализирован. Метод: get_status - main.py - 100
2024-11-12 09:33:38,800 - logger - INFO - robot_app еще не инициализирован. Метод: get_world_coordinates - main.py - 100
2024-11-12 09:33:38,800 - logger - INFO - robot_app еще не инициализирован. Метод: get_axis_coordinates - main.py - 100
2024-11-12 09:33:38,801 - logger - INFO - robot_app еще не инициализирован. Метод: get_command_count - main.py - 100
2024-11-12 09:33:39,823 - logger - INFO - Connect to 0 by SHARED_MEMORY - client_socket.py - 130
2024-11-12 09:33:41,584 - logger - INFO - not_connected - robot.py - 52
2024-11-12 09:33:41,994 - logger - INFO - urdf/sample.urdf - client_socket.py - 136
2024-11-12 09:33:44,286 - logger - INFO - connected - robot.py - 52

34
poetry.lock generated
View File

@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand.
# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.
[[package]]
name = "numpy"
@ -161,6 +161,36 @@ files = [
{file = "popsicle-0.9.6-cp312-cp312-win_arm64.whl", hash = "sha256:c40d8301b08690b041ed5710f0e9a63bf83c48ab51f5cf015b6fb7cf95921744"},
]
[[package]]
name = "psutil"
version = "6.1.0"
description = "Cross-platform lib for process and system monitoring in Python."
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7"
files = [
{file = "psutil-6.1.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:ff34df86226c0227c52f38b919213157588a678d049688eded74c76c8ba4a5d0"},
{file = "psutil-6.1.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:c0e0c00aa18ca2d3b2b991643b799a15fc8f0563d2ebb6040f64ce8dc027b942"},
{file = "psutil-6.1.0-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:000d1d1ebd634b4efb383f4034437384e44a6d455260aaee2eca1e9c1b55f047"},
{file = "psutil-6.1.0-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:5cd2bcdc75b452ba2e10f0e8ecc0b57b827dd5d7aaffbc6821b2a9a242823a76"},
{file = "psutil-6.1.0-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:045f00a43c737f960d273a83973b2511430d61f283a44c96bf13a6e829ba8fdc"},
{file = "psutil-6.1.0-cp27-none-win32.whl", hash = "sha256:9118f27452b70bb1d9ab3198c1f626c2499384935aaf55388211ad982611407e"},
{file = "psutil-6.1.0-cp27-none-win_amd64.whl", hash = "sha256:a8506f6119cff7015678e2bce904a4da21025cc70ad283a53b099e7620061d85"},
{file = "psutil-6.1.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:6e2dcd475ce8b80522e51d923d10c7871e45f20918e027ab682f94f1c6351688"},
{file = "psutil-6.1.0-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:0895b8414afafc526712c498bd9de2b063deaac4021a3b3c34566283464aff8e"},
{file = "psutil-6.1.0-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9dcbfce5d89f1d1f2546a2090f4fcf87c7f669d1d90aacb7d7582addece9fb38"},
{file = "psutil-6.1.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:498c6979f9c6637ebc3a73b3f87f9eb1ec24e1ce53a7c5173b8508981614a90b"},
{file = "psutil-6.1.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d905186d647b16755a800e7263d43df08b790d709d575105d419f8b6ef65423a"},
{file = "psutil-6.1.0-cp36-cp36m-win32.whl", hash = "sha256:6d3fbbc8d23fcdcb500d2c9f94e07b1342df8ed71b948a2649b5cb060a7c94ca"},
{file = "psutil-6.1.0-cp36-cp36m-win_amd64.whl", hash = "sha256:1209036fbd0421afde505a4879dee3b2fd7b1e14fee81c0069807adcbbcca747"},
{file = "psutil-6.1.0-cp37-abi3-win32.whl", hash = "sha256:1ad45a1f5d0b608253b11508f80940985d1d0c8f6111b5cb637533a0e6ddc13e"},
{file = "psutil-6.1.0-cp37-abi3-win_amd64.whl", hash = "sha256:a8fb3752b491d246034fa4d279ff076501588ce8cbcdbb62c32fd7a377d996be"},
{file = "psutil-6.1.0.tar.gz", hash = "sha256:353815f59a7f64cdaca1c0307ee13558a0512f6db064e92fe833784f08539c7a"},
]
[package.extras]
dev = ["black", "check-manifest", "coverage", "packaging", "pylint", "pyperf", "pypinfo", "pytest-cov", "requests", "rstcheck", "ruff", "sphinx", "sphinx_rtd_theme", "toml-sort", "twine", "virtualenv", "wheel"]
test = ["pytest", "pytest-xdist", "setuptools"]
[[package]]
name = "pybullet"
version = "3.2.6"
@ -294,4 +324,4 @@ files = [
[metadata]
lock-version = "2.0"
python-versions = "^3.10.11"
content-hash = "477456fef4701073ccbd5d5d1815632f60b9b74f660c90ea5a7303a5701765e1"
content-hash = "2e279718cfdf0983013b0777dcfbf042a94486d249ffac5db270d6aa337ca3f4"

View File

@ -16,6 +16,7 @@ popsicle = "^0.9.6"
pillow = "^11.0.0"
pyqt6 = "^6.7.1"
setuptools = "^75.3.0"
psutil = "^6.1.0"
[build-system]
requires = ["poetry-core"]

View File

@ -2,6 +2,7 @@ import subprocess
import argparse
import sys
import signal
import psutil
# Параметры для процессов
server_process = None
@ -14,17 +15,25 @@ def usage():
sys.exit(1)
def terminate_process(process):
"""Функция для корректного завершения процесса и всех его дочерних процессов"""
if process:
proc = psutil.Process(process.pid)
for child in proc.children(recursive=True):
child.terminate()
proc.terminate()
proc.wait()
# Обработчик для сигналов выхода
def cleanup():
def cleanup(*args):
"""Функция для остановки серверов при выходе"""
global server_process, test_server_process
print("Остановка серверов...")
if server_process:
server_process.terminate()
server_process.wait()
if test_server_process:
test_server_process.terminate()
test_server_process.wait()
terminate_process(server_process)
terminate_process(test_server_process)
print("Серверы остановлены.")
sys.exit(0) # Завершение работы после очистки
# Назначаем функции очистки для сигналов
@ -95,7 +104,12 @@ if args.test_socket:
else:
# Запуск основного скрипта main.exe
subprocess.run(
[poetry_path, "run", "python", "main.py",]
[
poetry_path,
"run",
"python",
"main.py",
]
) # Путь к исполняемому файлу
# Очистка после завершения