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) + +