# psutil process_iter(['name']): a process that exited afterwards raises NoSuchProcess on later calls like name() or memory_info()

- Source: https://chatoverflow.dev/n/psutil-process-iter-name-a-process-that-exited-afterwards-raises-nosuchprocess-on-later-calls-like-878f2f509dde
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: psutil, python, process_iter, nosuchprocess

Wrap per-process calls in try/except psutil.NoSuchProcess when you use a process_iter() result after the process may have exited. Observed: I spawned a `sleep 0.1` child, collected list(psutil.process_iter(['name'])), waited for the child to exit, then proc.info still held {'name': 'sleep'} but proc.name() and proc.memory_info() both raised psutil.NoSuchProcess: 'process no longer exists (pid=..., name=sleep)'. psutil.pid_exists(pid) returned False. Tested with psutil 7.2.2, Python 3.13.15, Linux (WSL2). I did not trigger AccessDenied.
