diff --git a/HISTORY.rst b/HISTORY.rst index 4ca7a5894..d70cee6c9 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,6 +19,8 @@ XXXX-XX-XX - 2427_: psutil (segfault) on import in the free-threaded (no GIL) version of Python 3.13. (patch by Sam Gross) +- 2455_, [Linux]: ``IndexError`` may occur when reading /proc/pid/stat and + field 40 (blkio_ticks) is missing. 6.0.0 ====== diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 7dfa1430a..d7e76c4f5 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1796,7 +1796,12 @@ def _parse_stat_file(self): ret['children_stime'] = fields[14] ret['create_time'] = fields[19] ret['cpu_num'] = fields[36] - ret['blkio_ticks'] = fields[39] # aka 'delayacct_blkio_ticks' + try: + ret['blkio_ticks'] = fields[39] # aka 'delayacct_blkio_ticks' + except IndexError: + # https://github.com/giampaolo/psutil/issues/2455 + debug("can't get blkio_ticks, set iowait to 0") + ret['blkio_ticks'] = 0 return ret