Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when piping to less #77

Closed
polyzen opened this issue Jun 30, 2016 · 5 comments
Closed

Error when piping to less #77

polyzen opened this issue Jun 30, 2016 · 5 comments

Comments

@polyzen
Copy link
Contributor

polyzen commented Jun 30, 2016

Sometimes a stack trace occurs after quitting less (apparently only when there's actual output):

~ > urlwatch |less                                                                     
Traceback (most recent call last):
  File "/usr/bin/urlwatch", line 375, in <module>
    main(parser.parse_args())
  File "/usr/bin/urlwatch", line 342, in main
    report.finish()
  File "/usr/lib/python3.5/site-packages/urlwatch/handler.py", line 128, in finish
    ReporterBase.submit_all(self, self.job_states, duration)
  File "/usr/lib/python3.5/site-packages/urlwatch/reporters.py", line 89, in submit_all
    cls(report, cfg, job_states, duration).submit()
  File "/usr/lib/python3.5/site-packages/urlwatch/reporters.py", line 304, in submit
    print(self._green(line))
BrokenPipeError: [Errno 32] Broken pipe
zsh: exit 1     urlwatch | 
zsh: done       less

urlwatch 2.2
less 481
Arch Linux Arm

@brbsix
Copy link
Contributor

brbsix commented Jul 1, 2016

Placing the following code near the top of urlwatch will suppress the error:

import signal

# ignore broken pipe
signal.signal(signal.SIGPIPE, signal.SIG_DFL)

Maybe @thp can add it?

Upon further examination, it appears this will also suppress any SIGPIPE on a socket. Not sure if this behavior will pose a problem.

@thp
Copy link
Owner

thp commented Jul 12, 2016

Looks like when a SIGPIPE for a socket is received, the network send will return an error, so that should be good. I guess I'll add this to Git now.

@polyzen
Copy link
Contributor Author

polyzen commented Jul 12, 2016

Glad this could get sorted so quickly! Thank you both.

@thp thp closed this as completed in 9c675de Jul 12, 2016
@DerEineDa
Copy link

DerEineDa commented Nov 8, 2016

I get this on my Fedora 24 workstation after installing urlwatch with pip:

$ urlwatch   File "/usr/bin/urlwatch", line 93
  ...
  ^
SyntaxError: invalid syntax

because of the "..." in commit 9c675de .

Edit: Sorry, that seems to be correct python3 syntax.

@thp
Copy link
Owner

thp commented Nov 26, 2016

@DerEineDa as you probably have already noticed in your edit, you need to install urlwatch using Python 3's PIP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants