[Twisted-Python] Problems with inlineCallback, Deferred, yield and Python 3 in buildbot

Glyph Lefkowitz glyph at twistedmatrix.com
Thu Jan 26 15:34:04 MST 2017


> On Jan 26, 2017, at 1:45 AM, Craig Rodrigues <rodrigc at crodrigues.org> wrote:
> 
> On Wed, Jan 25, 2017 at 10:06 AM, Phil Mayers <p.mayers at imperial.ac.uk <mailto:p.mayers at imperial.ac.uk>> wrote:
> 
> Related, see:
> 
> http://stackoverflow.com/questions/32139885/yield-in-list-comprehensions-and-generator-expressions <http://stackoverflow.com/questions/32139885/yield-in-list-comprehensions-and-generator-expressions>
> 
> http://bugs.python.org/issue10544 <http://bugs.python.org/issue10544>
> 
> Basically, don't use yield inside comprehensions if you don't want weirdness, AFAICT :o/
> 
> 
> Yes, that's the exact issue!
> Pointed out to me on the python-dev list:
> 
> https://mail.python.org/pipermail/python-dev/2017-January/147242.html <https://mail.python.org/pipermail/python-dev/2017-January/147242.html>
> 
> My vote is that this is a bug in Python.

Discussing on that bug, I discovered that this is sort-of fixed in python 3.6; not for generators, but for coroutines.  You can have an 'async def' function that does 'await' inside a generator and it should work.

Note that this is new in 3.6, and doesn't work in 3.5.

-glyph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20170126/7c01cb48/attachment-0002.html>


More information about the Twisted-Python mailing list