[Twisted-Python] How to chain deferred calls

vitaly at synapticvision.com vitaly at synapticvision.com
Thu Oct 22 18:38:26 EDT 2009


me too,
may be its because of the way I'm calling the chain:

return (
   self.abc1().
   addErrback(self.handleFailure1).
   addCallback(self.abc2,args).
   addCallback(self.abc3).
   addErrback(self.handleFailure2)
)

I see no call to self.handleFailure1() at all, abc1() just fail on  
exception (if it was raised).

Quoting "Valeriy Pogrebitskiy" <vpogrebi at verizon.net>:

> I am confused... If an exception is being raised in adc1() - errback is
> supposed to be called and passed your Exception instance (wrapped up as an
> instance of twisted.python.failure.Failure).
>
> Kind regards,
>
> Valeriy Pogrebitskiy
> Email: vpogrebi at iname.com
>
>
> -----Original Message-----
> From: twisted-python-bounces at twistedmatrix.com
> [mailto:twisted-python-bounces at twistedmatrix.com] On Behalf Of
> vitaly at synapticvision.com
> Sent: Thursday, October 22, 2009 2:02 PM
> To: twisted-python at twistedmatrix.com
> Subject: Re: [Twisted-Python] How to chain deferred calls
>
>
> Thank you for response.
>
> the issue is if adc1() will raise up an exception, than following it
> .addErrback() will never be called cause adc1() will exit or raise
> Exception.
>
> Quoting "Valeriy Pogrebitskiy" <vpogrebi at verizon.net>:
>
>> Add another .addErrback() directly after adc1() - to handle that
>> specific exception...
>>
>>
>> Kind regards,
>>
>> Valeriy Pogrebitskiy
>> vpogrebi at verizon.net
>>
>>
>>
>>
>> On Oct 21, 2009, at 4:12 PM, vitaly at synapticvision.com wrote:
>>
>>> hi,
>>> how can I chain in defer methods that could raise exception while
>>> showing the exception that coming from method? I mean, if I'll do:
>>> return (
>>>   adc1().abc2().abc3().addErrback("Common2AllException")
>>> )
>>> than "Common2AllException" will be raised if abc1() raise Exception,
>>> but I'd like to see the adc1() own exception (and not
>>> "Common2AllException") ?
>>>
>>>
>>>
>>> t = Test()
>>> def abc1(self):
>>>   if t.test() is None:
>>>     raise Exception("Error11")
>>>   else:
>>>     return 1
>>>
>>> def abc2(self):
>>>   if t.test() is None:
>>>     raise Exception("Error12")
>>>   else:
>>>     return 1
>>>
>>> def abc3(self):
>>>   if t.test() is None:
>>>     raise Exception("Error13")
>>>   else:
>>>     return 1
>>>
>>>
>>>
>>>
>>> Appreciate the help.
>>>
>>>
>>> _______________________________________________
>>> Twisted-Python mailing list
>>> Twisted-Python at twistedmatrix.com
>>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>
>>
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>
>
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>





More information about the Twisted-Python mailing list