Skip to content

Commit cc4361c

Browse files
get_process_children is updated
1 parent 230e562 commit cc4361c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: testgres/operations/local_ops.py

+1
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ def get_pid(self):
418418
return os.getpid()
419419

420420
def get_process_children(self, pid):
421+
assert type(pid) == int # noqa: E721
421422
return psutil.Process(pid).children()
422423

423424
# Database control

Diff for: testgres/operations/remote_ops.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -599,15 +599,16 @@ def get_pid(self):
599599
return int(self.exec_command("echo $$", encoding=get_default_encoding()))
600600

601601
def get_process_children(self, pid):
602-
command = ["ssh"] + self.ssh_args + [self.ssh_dest, f"pgrep -P {pid}"]
602+
assert type(pid) == int # noqa: E721
603+
command = ["ssh"] + self.ssh_args + [self.ssh_dest, "pgrep", "-P", str(pid)]
603604

604605
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
605606

606607
if result.returncode == 0:
607608
children = result.stdout.strip().splitlines()
608609
return [PsUtilProcessProxy(self, int(child_pid.strip())) for child_pid in children]
609-
else:
610-
raise ExecUtilException(f"Error in getting process children. Error: {result.stderr}")
610+
611+
raise ExecUtilException(f"Error in getting process children. Error: {result.stderr}")
611612

612613
# Database control
613614
def db_connect(self, dbname, user, password=None, host="localhost", port=5432):

0 commit comments

Comments
 (0)