Skip to content

Commit 7b2e72f

Browse files
committed
fix: process termination
1 parent af837cc commit 7b2e72f

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

.pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ E0611: no-name-in-module
2020
R0903: Too few public methods
2121

2222
[IMPORTS]
23-
ignored-modules=os,io
23+
ignored-modules=os,io,psutil
2424

2525
[DESIGN]
2626
# min-public-methods=1

operate/services/service.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from pathlib import Path
3333
from venv import main as venv_cli
3434

35+
import psutil
3536
from aea.__version__ import __version__ as aea_version
3637
from aea.configurations.constants import (
3738
DEFAULT_LEDGER,
@@ -428,7 +429,15 @@ def _start_tendermint(working_dir: Path) -> None:
428429

429430
def _kill_process(pid: int) -> None:
430431
"""Kill process."""
432+
print(f"Trying to kill process: {pid}")
431433
while True:
434+
if not psutil.pid_exists(pid=pid):
435+
return
436+
if psutil.Process(pid=pid).status() in (
437+
psutil.STATUS_DEAD,
438+
psutil.STATUS_ZOMBIE,
439+
):
440+
return
432441
try:
433442
os.kill(
434443
pid,
@@ -440,7 +449,7 @@ def _kill_process(pid: int) -> None:
440449
)
441450
except OSError:
442451
return
443-
time.sleep(3)
452+
time.sleep(1)
444453

445454

446455
def _stop_agent(working_dir: Path) -> None:

poetry.lock

+29-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ requests-toolbelt = "1.0.0"
4343
starlette = "==0.36.3"
4444
uvicorn = "==0.27.0"
4545
web3 = "==6.1.0"
46+
psutil = "^5.9.8"
4647

4748
[build-system]
4849
requires = ["poetry-core"]

tox.ini

+3
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,6 @@ ignore_missing_imports = True
212212

213213
[mypy-werkzeug.*]
214214
ignore_missing_imports = True
215+
216+
[mypy-psutil.*]
217+
ignore_missing_imports = True

0 commit comments

Comments
 (0)