[Twisted-Python] inlineCallbacks: multiple yielding same Defferred behaviour

Laurens Van Houtven _ at lvh.cc
Mon Jan 28 01:47:12 MST 2013


I'm not entirely sure why you feel this is unintuitive or why you should
need a workaround; in any other case, deferreds work pretty much the same
way.

When reading this code, the first question that pops up in my head is: why
are you doing this instead of just using the result that you already have
(and assigned to a name)? How did this  waiting-twice-on-one-deferred
happen?


On Mon, Jan 28, 2013 at 8:47 AM, Sergey V. Gerasimov <sergun at gmail.com>wrote:

> It’s not intuitively clear why multiple yielding the same Defferred in
> function decorated with defer.inlineCallbacks get different results:****
>
> ** **
>
> @defer.inlineCallbacks****
>
> def f():****
>
>                 d = defer.succeed(1)****
>
>                 result = yield d****
>
> print result****
>
>                 result = yield d****
>
> print result****
>
> ** **
>
> Output:****
>
> 1****
>
> None****
>
> ** **
>
> Probably we SHOULD NOT think if “d” was or was not yielded before when
> using inlineCallbacks..****
>
> ** **
>
> Are they some workarounds?****
>
> ** **
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>


-- 
cheers
lvh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20130128/61ed4edf/attachment.html>


More information about the Twisted-Python mailing list