def __init__(self, generator): base.LowMemoryDeferred.__init__(self) self._generator = generator self._state = STATE_NORMAL self._current = None self._context = context.current() self._step(None)
def call(*args, **kwargs): """The new function.""" # Save and restore the context afterwards so fn() doesn't interfere with other deferreds current = context.current() reprFn = None if args[:1] and hasattr(args[0], 'describeDeferred'): reprFn = args[0].describeDeferred className = None if isMethod and args: try: className = args[0].__class__.__name__ except AttributeError: pass d = InlinedCallbacks(fn(*args, **kwargs), reprFn=reprFn, className=className) context.setCurrent(current) if d.called: if isinstance(d.result, failure.Failure): f = d.result d.addErrback( lambda _: None ) # Eat the error so we don't get Unhandled Error In Deferred. f.raiseException() else: return d.result else: return d
def call(*args, **kwargs): """The new function.""" # Save and restore the context afterwards so fn() doesn't interfere with other deferreds current = context.current() reprFn = None if args[:1] and hasattr(args[0], 'describeDeferred'): reprFn = args[0].describeDeferred className = None if isMethod and args: try: className = args[0].__class__.__name__ except AttributeError: pass d = InlinedCallbacks(fn(*args, **kwargs), reprFn=reprFn, className=className) context.setCurrent(current) if d.called: if isinstance(d.result, failure.Failure): f = d.result d.addErrback(lambda _: None) # Eat the error so we don't get Unhandled Error In Deferred. f.raiseException() else: return d.result else: return d
def __init__(self, generator, reprFn=None, className=None): base.LowMemoryDeferred.__init__(self) self._generator = generator self._state = STATE_NORMAL self._current = None self._context = context.current() self._step(None) self._reprFn = reprFn self._className = className
def call(*args, **kwargs): """The new function.""" # Save and restore the context afterwards so fn() doesn't interfere with other deferreds current = context.current() d = InlinedCallbacks(fn(*args, **kwargs)) context.setCurrent(current) if d.called: if isinstance(d.result, failure.Failure): f = d.result d.addErrback(lambda _: None) # Eat the error so we don't get Unhandled Error In Deferred. f.raiseException() else: return d.result else: return d