diff --git a/requirements.txt b/requirements.txt index b1ac0bb8..a5c9ce48 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,7 +21,6 @@ opencv-python==4.5.4.60; python_version>="3.10" pep8-naming==0.13.3 pre-commit==2.21.0; python_version<"3.8" pre-commit==3.2.2; python_version>="3.8" -psutil==5.9.5 pydantic==1.10.7 recommonmark==0.7.1 requests==2.31.0 diff --git a/webenabled/mcsweb.py b/webenabled/mcsweb.py index 6fea1abc..22e028aa 100644 --- a/webenabled/mcsweb.py +++ b/webenabled/mcsweb.py @@ -135,24 +135,25 @@ def handle_keypress(): @app.route("/exit_unity", methods=["POST"]) def exit_unity(): app.logger.info("=" * 30) - mcs_interface, unique_id = get_mcs_interface(request, "exit unity") + mcs_interface, unique_id = get_mcs_interface(request, "Exit Unity") if mcs_interface is None: app.logger.warn("Cannot load MCS interface") return controller_pid = mcs_interface.get_controller_pid() - unity_proc_name = 'MCS-AI2-THOR' app.logger.info( "Attempting to clean up processes after browser has been closed.") - for p in psutil.process_iter(['name']): - if p.info['name'] == unity_proc_name: - app.logger.info(f"Found Unity process: {p}, will attempt to end.") - p.kill() - for p in psutil.process_iter(['pid']): if p.info['pid'] == controller_pid: + children = p.children(recursive=True) + for c_process in children: + app.logger.info( + f"Found child process of controller: {c_process}, " + f"will attempt to end.") + c_process.kill() + app.logger.info( f"Found controller process: {p}, will attempt to end.") p.kill() @@ -161,7 +162,7 @@ def exit_unity(): unique_id = request.cookies.get("uniq_id") app.logger.info( - f"Clear user session {unique_id}") + f"Clear user session for: {unique_id}") del session[unique_id] resp = jsonify( diff --git a/webenabled/requirements.txt b/webenabled/requirements.txt index 0aac5144..f2af6717 100644 --- a/webenabled/requirements.txt +++ b/webenabled/requirements.txt @@ -6,4 +6,5 @@ flake8==5.0.4; python_version<"3.8" flake8==6.0.0; python_version>="3.8" isort==5.11.5; python_version<"3.8" isort==5.12.0; python_version>="3.8" +psutil==5.9.5 pytest==7.3.0