Bug 810953 - Don't raise KeyboardInterrupt
Don't raise KeyboardInterrupt
Status: NEW
Product: Fedora
Classification: Fedora
Component: python-urlgrabber (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: James Antill
Fedora Extras Quality Assurance
: FutureFeature
Depends On:
  Show dependency treegraph
Reported: 2012-04-09 13:57 EDT by Kamil Páral
Modified: 2014-06-09 04:38 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Kamil Páral 2012-04-09 13:57:17 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).

Thank you.

Version-Release number of selected component (if applicable):
Comment 1 Fedora End Of Life 2013-04-03 11:08:05 EDT
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:
Comment 2 Daniel Miranda 2014-06-07 05:50:28 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.