This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asyncio: C implemeted Future cause Tornado test fail
Type: behavior Stage: resolved
Components: asyncio Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: methane Nosy List: gvanrossum, methane, python-dev, socketpair, terry.reedy, yselivanov
Priority: high Keywords: patch

Created on 2016-10-13 12:43 by methane, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
future-iter-send.patch methane, 2016-10-21 01:37 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (9)
msg278569 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2016-10-13 12:43
https://travis-ci.org/tornadoweb/tornado/jobs/167252979
msg278686 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2016-10-15 02:11
Another test failure is reported.

> I have setup a 3.6 build on Travis of our project GNS3 and it seem to fail.
> https://travis-ci.org/GNS3/gns3-server/builds/167703118
msg279095 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2016-10-21 01:37
pure Python Future.__iter__ don't use what yield-ed.

    def __iter__(self):
        if not self.done():
            self._asyncio_future_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.

I felt no-None value is sent by iter.send(val) wasn't make sense.
But Tornado did it (maybe, for compatibility to Tornado's generator.)

So this patch ignores when non-None value is passed.
Additionally, I moved NEWS entry about C Future from "core and builtin"
section to "library" section.
msg279104 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2016-10-21 03:23
Test failure in GNS3 seems not relating to this.
It may be fixed via #28492, maybe.
msg279150 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2016-10-21 21:00
The patch looks good.  2 things:

- It appears it also touches Misc/NEWS a bit too much. Please make sure to not to commit that.

- I'd also add a comment explaining why we ignore values passed to FI.send() and simply send None.  The reason is how Future.__iter__ is designed:

   class Future:
      def __iter__(self):
        if not self.done():
            self._asyncio_future_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.

^-- Future.__iter__ doesn't care about values that are pushed to the generator, it just returns "self.result()".
msg279382 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-10-25 10:11
New changeset b471447352ac by INADA Naoki in branch '3.6':
Issue #28430: Fix iterator of C implemented asyncio.Future doesn't
https://hg.python.org/cpython/rev/b471447352ac

New changeset bd141ec2973a by INADA Naoki in branch 'default':
Issue #28430: Fix iterator of C implemented asyncio.Future doesn't
https://hg.python.org/cpython/rev/bd141ec2973a
msg279388 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2016-10-25 10:31
> - It appears it also touches Misc/NEWS a bit too much. Please make sure to not to commit that.

I wont to move move this entry from "Core and Builtins" section to "Library" section:

- Issue #26081: Added C implementation of asyncio.Future.
  Original patch by Yury Selivanov.

May I do it?
msg279404 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-10-25 13:32
+- Issue #28430: Fix iterator of C implemented asyncio.Future doesn't accept

+  non-None value is passed to it.send(val).

This NEWS entry is not a coherent English sentence.  Please revise.  I don't understand it well enough to suggest a revision, but would review a replacement.
msg279406 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2016-10-25 13:39
I'm sorry about my bad English.

> Fix iterator of C implemented asyncio.Future

This meant:

fut = asyncio.Future()  # C implemented version of asyncio.Future
it = iter(fut)  # Iterator of it
it.send(42)     # raised TypeError before. It was not compatible with Python version of asyncio.Future
History
Date User Action Args
2022-04-11 14:58:38adminsetgithub: 72616
2017-03-31 16:36:16dstufftsetpull_requests: + pull_request904
2016-10-25 13:39:36methanesetmessages: + msg279406
2016-10-25 13:32:18terry.reedysetnosy: + terry.reedy
messages: + msg279404
2016-10-25 10:31:07methanesetstatus: open -> closed
resolution: fixed
messages: + msg279388

stage: commit review -> resolved
2016-10-25 10:11:52python-devsetnosy: + python-dev
messages: + msg279382
2016-10-21 21:00:01yselivanovsetmessages: + msg279150
2016-10-21 03:23:50methanesetmessages: + msg279104
2016-10-21 01:37:15methanesetfiles: + future-iter-send.patch
keywords: + patch
messages: + msg279095

stage: commit review
2016-10-15 02:11:45methanesetmessages: + msg278686
2016-10-14 14:35:39socketpairsetnosy: + socketpair
2016-10-13 12:43:15methanecreate