示例#1
0
 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)
示例#2
0
 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)
示例#3
0
    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
示例#4
0
  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
示例#5
0
 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
示例#6
0
 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
示例#7
0
  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
示例#8
0
    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