[Python-Dev] PEP 3152 and yield from Future() (original) (raw)

Victor Stinner victor.stinner at gmail.com
Thu Apr 23 10:43:11 CEST 2015


(I prefer to start a new thread, the previous one is too long for me :-))

Hi,

I'm still trying to understand how the PEP 3152 would impact asyncio. Guido suggests to replace "yield from fut" with "cocall fut()" (add parenthesis) and so add a cocall() method to asyncio.Future. Problem: PEP 3152 says "A cofunction (...) does not contain any yield or yield from expressions". Currently, Future.iter() is implemented using yield:

def __iter__(self):
    if not self.done():
        self._blocking = True
        yield self  # This tells Task to wait for completion.
    assert self.done(), "yield from wasn't used with future"
    return self.result()  # May raise too.

From my understanding, the PEP 3151 simply does not support asyncio.Future. Am I right?

How is it possible to suspend a cofunction if it's not possible to use yield?

If waiting for a future in a cofunction is not supported, the PEP 3151 is useless for asyncio, since asyncio completly relies on futures.

Victor



More information about the Python-Dev mailing list