question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Crash when bpytop started with closed STDIN

See original GitHub issue

Describe the bug

bpytop crashes when started after installation with PackageKit command-not-found wrapper. I see this error in the console:

Traceback (most recent call last):
File "/usr/bin/bpytop", line 5411, in <module>
main()
File "/usr/bin/bpytop", line 5293, in main
Term.echo(False)
File "/usr/bin/bpytop", line 651, in echo
(iflag, oflag, cflag, lflag, ispeed, ospeed, cc) = termios.tcgetattr(sys.stdin.fileno())
termios.error: (25, 'Inappropriate ioctl for device')

To Reproduce

  1. Remove bpytop with package manager;
  2. Run /usr/libexec/pk-command-not-found bpytop and install bpytop again;
  3. Crash.

Expected behavior

No crash.

Info (please complete the following information):

  • bpytop version: 1.0.59
  • psutil version: 5.7.2
  • Linux distribution and version: Fedora 33 x86_64
  • Terminal used: konsole
  • Font used: JetBrains Mono NL
  • Python version: 3.9.1

Additional context

17/08/20 (00:32:44) | ERROR: Non fatal error during disk io collection!
17/08/20 (00:32:44) | ERROR: Caused by outdated psutil version.
17/08/20 (00:32:44) | ERROR: not sure how to interpret line '   8       0 sda 389 0 14192 243 0 0 0 0 0 252 243 0 0 0 0 0 0\n'
Traceback (most recent call last):
  File "/usr/bin/bpytop", line 2697, in _collect
    io_counters = psutil.disk_io_counters(perdisk=True if SYSTEM == "Linux" else False, nowrap=True)
  File "/usr/lib64/python3.8/site-packages/psutil/__init__.py", line 2168, in disk_io_counters
    rawdict = _psplatform.disk_io_counters(**kwargs)
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1125, in disk_io_counters
    for entry in gen:
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1098, in read_procfs
    raise ValueError("not sure how to interpret line %r" % line)
ValueError: not sure how to interpret line '   8       0 sda 389 0 14192 243 0 0 0 0 0 252 243 0 0 0 0 0 0\n'
06/09/20 (19:48:59) | WARNING: psutil version 5.6.7 detected, version 5.7.0 or later required for full functionality!
06/09/20 (19:49:07) | ERROR: Non fatal error during disk io collection!
06/09/20 (19:49:07) | ERROR: Caused by outdated psutil version.
06/09/20 (19:49:07) | ERROR: not sure how to interpret line '   8       0 sda 515 0 14262 426 0 0 0 0 0 518 426 0 0 0 0 0 0\n'
Traceback (most recent call last):
  File "/usr/bin/bpytop", line 2716, in _collect
    io_counters = psutil.disk_io_counters(perdisk=True if SYSTEM == "Linux" else False, nowrap=True)
  File "/usr/lib64/python3.8/site-packages/psutil/__init__.py", line 2168, in disk_io_counters
    rawdict = _psplatform.disk_io_counters(**kwargs)
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1125, in disk_io_counters
    for entry in gen:
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1098, in read_procfs
    raise ValueError("not sure how to interpret line %r" % line)
ValueError: not sure how to interpret line '   8       0 sda 515 0 14262 426 0 0 0 0 0 518 426 0 0 0 0 0 0\n'
06/09/20 (19:50:10) | WARNING: psutil version 5.6.7 detected, version 5.7.0 or later required for full functionality!
06/09/20 (19:50:18) | ERROR: Non fatal error during disk io collection!
06/09/20 (19:50:18) | ERROR: Caused by outdated psutil version.
06/09/20 (19:50:18) | ERROR: not sure how to interpret line '   8       0 sda 515 0 14262 426 0 0 0 0 0 518 426 0 0 0 0 0 0\n'
Traceback (most recent call last):
  File "/usr/bin/bpytop", line 2716, in _collect
    io_counters = psutil.disk_io_counters(perdisk=True if SYSTEM == "Linux" else False, nowrap=True)
  File "/usr/lib64/python3.8/site-packages/psutil/__init__.py", line 2168, in disk_io_counters
    rawdict = _psplatform.disk_io_counters(**kwargs)
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1125, in disk_io_counters
    for entry in gen:
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1098, in read_procfs
    raise ValueError("not sure how to interpret line %r" % line)
ValueError: not sure how to interpret line '   8       0 sda 515 0 14262 426 0 0 0 0 0 518 426 0 0 0 0 0 0\n'
06/09/20 (19:51:44) | WARNING: psutil version 5.6.7 detected, version 5.7.0 or later required for full functionality!
06/09/20 (19:51:51) | ERROR: Non fatal error during disk io collection!
06/09/20 (19:51:51) | ERROR: Caused by outdated psutil version.
06/09/20 (19:51:51) | ERROR: not sure how to interpret line '   8       0 sda 515 0 14262 426 0 0 0 0 0 518 426 0 0 0 0 0 0\n'
Traceback (most recent call last):
  File "/usr/bin/bpytop", line 2716, in _collect
    io_counters = psutil.disk_io_counters(perdisk=True if SYSTEM == "Linux" else False, nowrap=True)
  File "/usr/lib64/python3.8/site-packages/psutil/__init__.py", line 2168, in disk_io_counters
    rawdict = _psplatform.disk_io_counters(**kwargs)
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1125, in disk_io_counters
    for entry in gen:
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1098, in read_procfs
    raise ValueError("not sure how to interpret line %r" % line)
ValueError: not sure how to interpret line '   8       0 sda 515 0 14262 426 0 0 0 0 0 518 426 0 0 0 0 0 0\n'
07/09/20 (15:53:12) | WARNING: psutil version 5.6.7 detected, version 5.7.0 or later required for full functionality!
07/09/20 (15:53:13) | ERROR: Non fatal error during disk io collection!
07/09/20 (15:53:13) | ERROR: Caused by outdated psutil version.
07/09/20 (15:53:13) | ERROR: not sure how to interpret line '   8       0 sda 445 0 14262 309 0 0 0 0 0 352 309 0 0 0 0 0 0\n'
Traceback (most recent call last):
  File "/usr/bin/bpytop", line 2716, in _collect
    io_counters = psutil.disk_io_counters(perdisk=True if SYSTEM == "Linux" else False, nowrap=True)
  File "/usr/lib64/python3.8/site-packages/psutil/__init__.py", line 2168, in disk_io_counters
    rawdict = _psplatform.disk_io_counters(**kwargs)
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1125, in disk_io_counters
    for entry in gen:
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1098, in read_procfs
    raise ValueError("not sure how to interpret line %r" % line)
ValueError: not sure how to interpret line '   8       0 sda 445 0 14262 309 0 0 0 0 0 352 309 0 0 0 0 0 0\n'
07/09/20 (15:53:30) | WARNING: psutil version 5.6.7 detected, version 5.7.0 or later required for full functionality!
07/09/20 (15:53:32) | ERROR: Non fatal error during disk io collection!
07/09/20 (15:53:32) | ERROR: Caused by outdated psutil version.
07/09/20 (15:53:32) | ERROR: not sure how to interpret line '   8       0 sda 445 0 14262 309 0 0 0 0 0 352 309 0 0 0 0 0 0\n'
Traceback (most recent call last):
  File "/usr/bin/bpytop", line 2716, in _collect
    io_counters = psutil.disk_io_counters(perdisk=True if SYSTEM == "Linux" else False, nowrap=True)
  File "/usr/lib64/python3.8/site-packages/psutil/__init__.py", line 2168, in disk_io_counters
    rawdict = _psplatform.disk_io_counters(**kwargs)
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1125, in disk_io_counters
    for entry in gen:
  File "/usr/lib64/python3.8/site-packages/psutil/_pslinux.py", line 1098, in read_procfs
    raise ValueError("not sure how to interpret line %r" % line)
ValueError: not sure how to interpret line '   8       0 sda 445 0 14262 309 0 0 0 0 0 352 309 0 0 0 0 0 0\n'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ZaWertuncommented, Jan 19, 2021

It can be crashed in bash with this command:

bpytop <&-

sys.stdin will be None when STDIN is closed (I’m wrong about sys.stdin.fileno(), not in this case).

0reactions
ZaWertuncommented, Jan 19, 2021
diff -r -U3 bpytop-1.0.59.orig/bpytop.py bpytop-1.0.59/bpytop.py
--- bpytop-1.0.59.orig/bpytop.py        2021-01-11 23:53:15.000000000 +0300
+++ bpytop-1.0.59/bpytop.py     2021-01-19 23:15:23.773718634 +0300
@@ -5280,6 +5280,10 @@
THEME: Theme

def main():
+       if sys.stdin is None or not(sys.stdin.isatty()):
+               print("Stdin is closed or not a tty, exiting...")
+               exit(1)
+
global THEME

Term.width = os.get_terminal_size().columns

@aristocratos what you say about this check?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Crashed with mouse click and drag · Issue #147 - GitHub
Describe the bug. bpytop running in a tmux pane. Runs fine, but when mouse is clicked and dragged it crashes with error. To...
Read more >
Issue 7111: abort when stderr is closed - Python tracker
Under Python 2.x, you don't get a crash but the behaviour is quite unhelpful ... If we want to allow for closed {stdin,...
Read more >
Python crashing at `input(...)` after reading from STDIN
You have already read from stdin until end of file, but you could read from the terminal device: import sys print(len(sys.stdin.read())) ...
Read more >
Xmobar doesn't appear unless I manually restart XMonad
Sometimes I notice that on initial startup, Xmobar shows up for a fraction of a second before disappearing completely (crash?) I have no...
Read more >
Software Packages in "kinetic" - Ubuntu
... abacas (1.3.1-9) [universe]: close gaps in genomic alignments from short reads ... [universe]: tools for automatically reporting Apport crash reports ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found