Red Hat Bugzilla – Bug 810953
Don't raise KeyboardInterrupt
Last modified: 2018-07-18 17:33:00 EDT
Description of problem:
My scripts using URLGrabber sometimes crash with KeyboardInterrupt. I can guarantee you I did not press Ctrl+C. It is possible that the script got terminated somehow, maybe, but definitely it was not a keyboard interrupt, which is a user-oriented action. I researched it originates from here:
> if errcode == 23 and code >= 200 and code < 299:
> err = URLGrabError(15, _('User (or something) called abort %s: %s') % (errurl, e))
> err.url = errurl
> # this is probably wrong but ultimately this is what happens
> # we have a legit http code and a pycurl 'writer failed' code
> # which almost always means something aborted it from outside
> # since we cannot know what it is -I'm banking on it being
> # a ctrl-c. XXXX - if there's a way of going back two raises to
> # figure out what aborted the pycurl process FIXME
> raise KeyboardInterrupt
Please _never_ raise KeyboardInterrupt, especially in libraries and low-level tools. That is ultimately confusing. Authors using your library usually don't guard their code against KeyboardInterrupt coming _from a library_. It is not even inherited from Exception!
The best approach is to create your own top-level exception (inherited from Exception) and then create more specific exceptions (inherited from your top-level one). Please replace places where you throw KeyboardInterrupt now with your custom exception (or even some standard one, still better).
Version-Release number of selected component (if applicable):
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.
(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)
More information and reason for this action is here:
This bug still exists and still bytes me when I'm trying to use urlgrabber. It makes no sense to ever raise a KeyboardInterrupt ever.
yum and related packages are no longer actively developed.
They are being replaced with dnf, dnf-utils, etc.
I'm closing this bug because it's most likely never going to be fixed.
If you still consider your bug report important, reopen it, please.