Bug 1066321

Summary: exception raised in python callbacks are ignored
Product: [Fedora] Fedora Reporter: Ales Kozumplik <akozumpl>
Component: librepoAssignee: Tomas Mlcoch <tmlcoch>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: jzeleny, tmlcoch
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: librepo-1.6.0-1.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-06 08:19:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ales Kozumplik 2014-02-18 09:09:01 UTC
hi, plaese see the sample below. the RuntimeError is never observed. I would expect it to be (as soon as possible) propagated outside of the download_packages() call. We don't want to have failing code silently rotting somewhere.

#! /usr/bin/python

import librepo

URL = 'http://mirrors.fedoraproject.org/metalink?repo=updates-released-f19&arch=x86_64'

def progress(*args):
    print(args)
    raise RuntimeError('some')

def main():
    h = librepo.Handle()
    h.setopt(librepo.LRO_MIRRORLIST, URL)
    h.repotype = librepo.LR_YUMREPO
    h.destdir = './'
    r = librepo.Result()
    h.interruptible = True
    h.connecttimeout = 1

    target = librepo.PackageTarget("texlive-collection-pstricks-svn30307.0-0.1.20130608_r30832.fc19.noarch.rpm",
                                   handle=h,
                                   progresscb=progress,
                                   cbdata="tyeah")
    librepo.download_packages([target])

if __name__ == '__main__':
    main()

Comment 1 Tomas Mlcoch 2014-02-18 16:01:07 UTC
Fix just pushed to HEAD.

During tomorrow I will add few more fixes and make a build.

Comment 2 Ales Kozumplik 2014-02-18 16:47:45 UTC
Looking at the fix I don't think it's going to show the traceback on an uncaught exception though, yes? Ideally, the Python layer should just transparently propagate the original exception up, either to be caught or let uncaught so we get the traceback.

Comment 3 Tomas Mlcoch 2014-02-19 13:04:50 UTC
In the original patch, there was missing proper "exception propagation" mechanism for the Handle.perform() method (but download_packages() was working properly).

Now, this is fixed and all uncaught exceptions are propagated properly from all functions that can call python callbacks (Handle.perform(), download_packages(), etc.).

Comment 4 Ales Kozumplik 2014-02-19 20:21:58 UTC
Excellent, thank you Tomas!

Comment 5 Fedora Update System 2014-02-25 08:38:57 UTC
librepo-1.6.0-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/librepo-1.6.0-1.fc20

Comment 6 Fedora Update System 2014-02-26 14:00:08 UTC
Package librepo-1.6.0-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing librepo-1.6.0-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-3120/librepo-1.6.0-1.fc20
then log in and leave karma (feedback).

Comment 7 Fedora Update System 2014-03-06 08:19:08 UTC
librepo-1.6.0-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.