Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to psutil when /proc/.../children isn't present #1864

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion sanic/reloader_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import signal
import subprocess
import sys

from multiprocessing import Process
from time import sleep

Expand Down Expand Up @@ -74,7 +73,15 @@ def kill_process_children_unix(pid):
"""
root_process_path = f"/proc/{pid}/task/{pid}/children"
if not os.path.isfile(root_process_path):
# Fall back to psutils
# Ubuntu 18.04 WSL2 doesn't have .../task/pid/children
import psutil

ppid = psutil.Process(pid)
for children in ppid.children(recursive=True):
os.kill(int(children.pid), signal.SIGTERM)
return

with open(root_process_path) as children_list_file:
children_list_pid = children_list_file.read().split()

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def open_local(paths, mode="r", encoding="utf8"):
"websockets>=7.0,<9.0",
"multidict>=4.0,<5.0",
"httpx==0.11.1",
"psutil>=5.7.0"
]

tests_require = [
Expand Down