From 519d7429e0fe379352e9535564616f4fd2433772 Mon Sep 17 00:00:00 2001 From: rgarcia-herrera Date: Mon, 28 Oct 2024 23:59:00 -0600 Subject: [PATCH] mejor orden --- ps_random_walk.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ps_random_walk.py b/ps_random_walk.py index 301b98c..c3518ef 100644 --- a/ps_random_walk.py +++ b/ps_random_walk.py @@ -11,13 +11,14 @@ def reporta(p): print(eighths_scale(p, scale), p.name()) - -p = psutil.Process(pid=random.choice(psutil.pids())) -print('random chose', reporta(p)) - +# walk from init +p = psutil.Process(pid=1) while True: + reporta(p) + sleep(1) + children = p.children() if children: @@ -25,11 +26,10 @@ while True: for subp in children])) print("\t↳", end="") - reporta(p) - else: p = psutil.Process(pid=random.choice(psutil.pids())) print('→', end="") - reporta(p) + +