Skip to content

Python version prints Traceback on KeyboardInterrupt #462

@evamiaou

Description

@evamiaou

If a KeyboardInterrupt happens while the python version is running, hyfetch will let python print the error traceback to the terminal:

Traceback (most recent call last):
  File "/home/eva/.local/bin/hyfetch", line 8, in <module>
    sys.exit(run_rust())
             ~~~~~~~~^^
  File "/home/eva/.local/lib/python3.13/site-packages/hyfetch/rs.py", line 24, in run_rust
    subprocess.run([str(pd)] + sys.argv[1:])
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/subprocess.py", line 556, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
                     ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/subprocess.py", line 1214, in communicate
    self.wait()
    ~~~~~~~~~^^
  File "/usr/lib64/python3.13/subprocess.py", line 1280, in wait
    return self._wait(timeout=timeout)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/subprocess.py", line 2066, in _wait
    (pid, sts) = self._try_wait(0)
                 ~~~~~~~~~~~~~~^^^
  File "/usr/lib64/python3.13/subprocess.py", line 2024, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
                 ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

The rust version exits directly with status 130. I believe the python version should aim to have the same behaviour.

One of the reasons why the user might stop the program this way is:

  • they use the fastfetch backend with the public ip feature
  • the server is not responding or they have a bad connection
  • they have disabled the timeout, or pressed Ctrl+C before the end of the timeout (for instance if they've set hyfetch to run as soon as the terminal opens and they're in a hurry)

System info:

  • OS: Fedora Linux 42 (KDE Plasma Desktop Edition) x86_64
  • Kernel: Linux 6.17.7-200.fc42.x86_64
  • Shell: fish 4.0.2
  • Terminal: konsole 25.8.2
  • Hyfetch: 2.0.4
  • fastfetch: 2.44.0 (x86_64)
  • Python: 3.13.9

I am willing to create a pull request that would fix the issue, if it is deemed appropriate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions