A collection of ideas and notes about stuff to implement in future versions.
(the “too late” section)
PROCFS_PATH should have been set_procfs_path().
virtual_memory() should have been memory_virtual().
swap_memory() should have been memory_swap().
Named tuples are problematic. Positional unpacking of named tuples could be deprecated. Return frozen dataclasses (with a common base class) instead of typing.NamedTuple. The base class would keep _fields, _asdict() and len() for compat, but __iter__ and __getitem__ would emit DeprecationWarning. Main concern: isinstance(x, tuple) would break.
process_iter(new_only=True)#2794: enrich Process.wait() return value with exit code enums.
net_if_addrs() could return AF_BLUETOOTH interfaces. E.g. https://pypi.org/project/netifaces does this.
Use resource.getrusage() to get current process CPU times (it has more precision).
(UNIX) Process.root() (different from cwd()).
(Linux) locked files via /proc/locks: https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-proc-locks.html
#269: NIC rx/tx queue. This should probably go into net_if_stats(). Figure out on what platforms this is supported. Linux: yes. Others?
Asynchronous psutil.Popen (see http://bugs.python.org/issue1191964)
(Windows) fall back on using WMIC for Process methods returning AccessDenied.
#613: thread names; patch for macOS available at: https://code.google.com/p/plcrashreporter/issues/detail?id=65 Sample code: https://github.com/janmojzis/pstree/blob/master/proc_kvm.c
scripts/taskmgr-gui.py (using tk).
system-wide number of open file descriptors:
Number of system threads.
psutil.proc_tree() something which obtains a {pid:ppid, ...} struct for all running processes in one shot. This can be factored out from Process.children() and exposed as a first class function. PROS: on Windows we can take advantage of ppid_map(), which is faster than iterating over all PIDs. CONS: scripts/pstree.py shows this can be easily done in the user code, so maybe it's not worth the addition.
advanced cmdline interface exposing the whole API and providing different kind of outputs (e.g. pprinted, colorized, json).
Linux: process cgroups (http://en.wikipedia.org/wiki/Cgroups). They look similar to prlimit() in terms of functionality but, uglier (they should allow limiting per-process network IO resources though, which is great). Needs further reading.
Python 3.3. exposed different sched.h functions: http://docs.python.org/dev/whatsnew/3.3.html#os http://bugs.python.org/issue12655 http://docs.python.org/dev/library/os.html#interface-to-the-scheduler It It might be worth to take a look and figure out whether we can include some of those in psutil.
os.times() provides elapsed times (Process.cpu_times() might as well?).
Enrich exception classes hierarchy on Python >= 3.3 / post PEP-3151 so that:
NoSuchProcess inherits from ProcessLookupErrorAccessDenied inherits from PermissionErrorTimeoutExpired inherits from TimeoutError (debatable) See: http://docs.python.org/3/library/exceptions.html#os-exceptionsProcess.threads() might grow an extra “id” parameter so that it can be used as:
>>> p = psutil.Process(os.getpid()) >>> p.threads(id=psutil.current_thread_id()) thread(id=2539, user_time=0.03, system_time=0.02) >>>
Note: this leads to questions such as "should we have a custom NoSuchThread exception? Also see issue #418. Also note: this would work with os.getpid() only. psutil.current_thread_id() might be desirable as per issue #418 though.
should TimeoutExpired exception have a ‘msg’ kwarg similar to NoSuchProcess and AccessDenied? Not that we need it, but currently we cannot raise a TimeoutExpired exception with a specific error string.
round `Process.memory_percent() result?
Source code of system monitoring tools (ps, top, vmstat, etc.) on various platforms. Useful as a reference when implementing or verifying psutil's platform-specific code.
Apple open-source distributions: https://github.com/apple-oss-distributions/
Repository: https://github.com/freebsd/freebsd-src
Repository: https://github.com/NetBSD/src
Repository: https://github.com/openbsd/src
Example sites using sphinx ablog: