KeyError when calling tearDown

Bug #409405 reported by John O'Brien
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu One Servers
Fix Released
Critical
Elliot Murphy
testresources
Fix Released
Undecided
Unassigned
testresources (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

We are getting the following error from testresources:

    test_putcontent_bad_prev_hash ... Traceback (most recent call last):
  File "/home/facundo/canonical/ubunet/trunk/lib/ubuntuone/storage/server/testing/testcase.py", line 288, in <lambda>
    d.addCallback(lambda _: ORMTestCase.tearDown(self))
  File "/usr/lib/pymodules/python2.6/testresources/__init__.py", line 390, in tearDown
    self.tearDownResources()
  File "/usr/lib/pymodules/python2.6/testresources/__init__.py", line 395, in tearDownResources
    result = self.__get_result()
  File "/usr/lib/pymodules/python2.6/testresources/__init__.py", line 377, in __get_result
    return frame[0].f_locals['result']
exceptions.KeyError: 'result'

I believe this is related to the tearDown being called from a callback.

The following change corrects issues we are experiencing https://pastebin.canonical.com/20795/

John O'Brien (jdobrien)
Changed in ubunet:
importance: Undecided → Critical
Revision history for this message
Robert Collins (lifeless) wrote :

The change (in the pastebin) is to check that result is actually present there.

I'd like to confirm whats going on; there may be a serious issue, or it might be shallow. What do you mean by 'tearDown being called from a callback' - could you get a backtrace of the error (e.g. by wrapping the access in
try:
except KeyError:
    import pdb;pdb.set_trace()

and when you get into pdb do
bt\n

-Rob

Revision history for this message
Jonathan Lange (jml) wrote : Re: [Bug 409405] Re: KeyError when calling tearDown

On Wed, Aug 5, 2009 at 10:24 PM, Robert
Collins<email address hidden> wrote:
> The change (in the pastebin) is to check that result is actually present
> there.
>
> I'd like to confirm whats going on; there may be a serious issue, or it might be shallow. What do you mean by 'tearDown being called from a callback'

In our IRC conversation earlier today, jdo implied that they are using
a Twisted TestCase that returns a Deferred from tearDown.

jml

Revision history for this message
Robert Collins (lifeless) wrote :

I've landed a fix straight into trunk to get John unblocked; if someone
would like to post-hoc review it that would be great.

The problem was that the stack looked like:
trial
<reactor>.run
tearDown
get_result

The .run frame was confusing, so I've guarded it more.

There was an oddity where a lambda was being called immediately rather
than lazily, but thats orthogonal, either way we should work.

-Rob

Revision history for this message
Elliot Murphy (statik) wrote :

I am attaching a debdiff that fixes the crashing when used with twisted testcases, this is the patch that robert has already committed upstream in testresources. Please upload.

Elliot Murphy (statik)
Changed in testresources:
status: New → Confirmed
Elliot Murphy (statik)
Changed in testresources (Ubuntu):
status: New → Confirmed
Elliot Murphy (statik)
Changed in testresources:
status: Confirmed → Fix Committed
Elliot Murphy (statik)
Changed in ubunet:
assignee: nobody → Elliot Murphy (statik)
milestone: none → w15
status: New → Fix Committed
Revision history for this message
Jonathan Lange (jml) wrote :

lifeless, the patch looks fine to me, but it would be nicer if it were accompanied by a unit test. Thanks for fixing it so promptly.

Revision history for this message
Elliot Murphy (statik) wrote :

I've uploaded this fix to a PPA for now, it's working great there.

Revision history for this message
Alessio Treglia (quadrispro) wrote :

testresources (0.2-0ubuntu2) karmic; urgency=low

 [ Elliot Murphy ]
 * Fix a crash with tearing down test suites when the result is not
   available. (Closes: #409405)

 [ Alessio Treglia ]
 * Bump Standards to 3.8.3:
   - Add ${misc:Depends} macro to Depends field.
 * Bump debhelper,cdbs build-dependencies (as per Python New policy).

Changed in testresources (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Julien Lavergne (gilir) wrote :

I unsubscribe ubuntu-universe-sponsors, the fix is already in Ubuntu.

Elliot Murphy (statik)
Changed in testresources:
status: Fix Committed → Fix Released
Changed in ubunet:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.