[Twisted-Python] t.i.task.Cooperator & inlineCallbacks mashup
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Wed Nov 2 09:08:42 EDT 2011
On 11:24 am, p.mayers at imperial.ac.uk wrote:
>I only just noticed today that if a generator passed to a
>CooperativeTask does:
>
> result = yield some_deferred()
>
>...it doesn't work, because CooperativeTask doesn't .send() the result
>of the deferred bacn into the generator.
>
>Is this intentional?
Yes. Cooperator is for iterators, not generators, making send unusable
in the general case. Cooperator also isn't a replacement for
inlineCallbacks.
You can build a wrapper for a generator that works together with
Cooperator and sends results back in. If it ends up being useful, it
might be something to add to Twisted.
Jean-Paul
>If not, would that behaviour be desirable? It seems
>like it would be a useful pattern to me.
>
>_______________________________________________
>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