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

Updating psutil call for new API #726

Merged
merged 2 commits into from
Sep 29, 2023
Merged
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
14 changes: 7 additions & 7 deletions swri_prefix_tools/xterm_prefix
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def child_func():
subscript = os.path.join(script_dir, 'xterm_prefix_' + sys.argv[1])

if not os.path.exists(subscript):
print "Could not find subscript %r" % subscript
print("Could not find subscript {}".format(subscript))
sys.exit(1)

# Launch the node in an xterm. We use exec so that the xterm
Expand All @@ -100,19 +100,19 @@ def get_child(pid, timeout=10.0):
while t < timeout:
proc = psutil.Process(pid)
if proc.status == psutil.STATUS_ZOMBIE:
print "Warning: process %d is defunct." % pid
print("Warning: process {} is defunct.".format(pid))
return None
if len(proc.get_children()) > 0:
if len(proc.children()) > 0:
break
time.sleep(0.1)
t += 0.1

children = [c.pid for c in proc.get_children()]
children = [c.pid for c in proc.children()]

if len(children) == 0:
return None
elif len(children) > 1:
print "Warning: Found multiple children, selecting the first..."
print("Warning: Found multiple children, selecting the first...")

return children[0]

Expand All @@ -129,14 +129,14 @@ def main_func(child):
# a new process that execed over that script.
grandchild = get_child(child)
if grandchild is None:
print "Found no running process for node. Quitting."
print("Found no running process for node. Quitting.")
sys.exit(1)

# Next we get the child of the bash script. This should be the
# actual node.
great_grandchild = get_child(grandchild)
if great_grandchild is None:
print "Found no running process for node. Quitting."
print("Found no running process for node. Quitting.")
sys.exit(1)

# Setup the signals that we want to forward to the child node.
Expand Down