{"action":"opened","issue":{"url":"https://api.github.com/repos/micropython/micropython/issues/2678","repository_url":"https://api.github.com/repos/micropython/micropython","labels_url":"https://api.github.com/repos/micropython/micropython/issues/2678/labels{/name}","comments_url":"https://api.github.com/repos/micropython/micropython/issues/2678/comments","events_url":"https://api.github.com/repos/micropython/micropython/issues/2678/events","html_url":"https://github.com/micropython/micropython/issues/2678","id":194926791,"number":2678,"title":"Unix build: uasyncio __await__ not called","user":{"login":"peterhinch","id":8437477,"avatar_url":"https://avatars.githubusercontent.com/u/8437477?v=3","gravatar_id":"","url":"https://api.github.com/users/peterhinch","html_url":"https://github.com/peterhinch","followers_url":"https://api.github.com/users/peterhinch/followers","following_url":"https://api.github.com/users/peterhinch/following{/other_user}","gists_url":"https://api.github.com/users/peterhinch/gists{/gist_id}","starred_url":"https://api.github.com/users/peterhinch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterhinch/subscriptions","organizations_url":"https://api.github.com/users/peterhinch/orgs","repos_url":"https://api.github.com/users/peterhinch/repos","events_url":"https://api.github.com/users/peterhinch/events{/privacy}","received_events_url":"https://api.github.com/users/peterhinch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-12T09:31:54Z","updated_at":"2016-12-12T09:31:54Z","closed_at":null,"body":"Is this special method supported? The following code behaves differently under CPython and MicroPython.\r\n```python\r\nimport uasyncio as asyncio\r\n\r\ndef genf(n):\r\n    while n:\r\n        print(n)\r\n        yield\r\n        n -= 1\r\n\r\nclass Foo():\r\n    def __iter__(self):\r\n        for n in range(5):\r\n            print('__iter__ called')\r\n            yield\r\n\r\n    def __await__(self):\r\n        print('__await__ called')\r\n        yield from genf(5)\r\n\r\n\r\nasync def bar():\r\n    foo = Foo()\r\n    print('waiting for foo')\r\n    await foo\r\n    print('done')\r\n\r\nasync def main(delay):\r\n    await asyncio.sleep(delay)\r\n    print(\"I've seen starships burn off the shoulder of Orion...\")\r\n    print(\"Time to die...\")\r\n\r\nloop = asyncio.get_event_loop()\r\nloop.create_task(bar())\r\nloop.run_until_complete(main(5))\r\n```\r\nUnder CPython the outcome is as expected: ``__iter__()`` is not called, ``__await__()`` is:\r\n```\r\nPython 3.5.2 (default, Dec  2 2016, 15:29:25) \r\n[GCC 4.8.4] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import rats6\r\nwaiting for foo\r\n__await__ called\r\n5\r\n4\r\n3\r\n2\r\n1\r\ndone\r\nI've seen starships burn off the shoulder of Orion...\r\nTime to die...\r\n>>> \r\n```\r\nUnder MicroPython the converse is true:\r\n```\r\nMicroPython v1.8.1-925-g46e59c5 on 2016-12-03; linux version\r\nUse Ctrl-D to exit, Ctrl-E for paste mode\r\n>>> import rats6\r\nwaiting for foo\r\n__iter__ called\r\n__iter__ called\r\n__iter__ called\r\n__iter__ called\r\n__iter__ called\r\ndone\r\nI've seen starships burn off the shoulder of Orion...\r\nTime to die...\r\n>>> \r\n```"}}
{"actor":{"display_login":"peterhinch"}}