Should GreenletExit trigger an errback in deferredGreenlet?

Bug #233874 reported by kmh
2
Affects Status Importance Assigned to Milestone
Corotwine
Invalid
Undecided
Unassigned

Bug Description

Just been playing around with corotwine - neat hack. I'm still trying to get my head around greenlets (and twisted!) so I may be missing something here, but is this supposed to happen?
---
from py.magic import greenlet
from corotwine.defer import deferredGreenlet

MAIN = greenlet.getcurrent()

def f():
    print 'f1'
    MAIN.switch()
    print 'f2'

fd = deferredGreenlet(f)
fd()
---
f1
Unhandled error in Deferred:
Traceback (most recent call last):
--- <exception caught here> ---
  File "/home/kmh/python/my-packages/corotwine/defer.py", line 104, in intermediateGreenletFunction
    d.callback(gfunction(*args, **kwargs))
  File "./greenlets/demo_corotwine_bug.py", line 9, in f
    MAIN.switch()
py.magic.greenlet.GreenletExit:

I think the problem is that intermediateGreenletFunction in deferredGreenlet has a blank try/except clause
that propagates the GreenletExit into the errback, when I imagine it should instead be re-raised.

kmh

Revision history for this message
Christopher Armstrong (radix) wrote :

It's not clear to me that this is a bug, and in fact it seems like reasonable behavior. You switched away from the greenlet when it was impossible for anything to switch back to it. Which means it's impossible for the greenlet to then provide a result to the deferred in any way.

Are you suggesting that the error should be raised synchronously from the call of fd(), instead of being errbacked on the Deferred? I don't see the point, and it seems a bit undesirable, since the point of deferredGreenlet is to encapsulate results of greenlets in Deferreds.

Revision history for this message
Christopher Armstrong (radix) wrote :

Sorry, brainfart in the last comment. In fact it's impossible to raise it synchronously from the call to fd(), since fd() must return immediately with the deferred, and a GreenletExit might happen any time in the future.

Revision history for this message
kmh (w-launchpad-kieranholland-com) wrote :

OK, sorry, brainfart was all mine. I thought I had a legitimate case where this could arise but on further thought it was quite illegit. My greenlet was indeed a bastard. <slinks off>

Revision history for this message
Christopher Armstrong (radix) wrote :

Sure thing, no problem :-)

Changed in corotwine:
status: New → Invalid
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.