(original) (raw)
On Thu, Apr 23, 2015 at 4:09 PM, Victor Stinner <victor.stinner@gmail.com> wrote:
(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
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com