<div dir="ltr">It has come to my attention (<a href="https://github.com/KeepSafe/aiohttp/issues/877">https://github.com/KeepSafe/aiohttp/issues/877</a>) that Python 3.5.2 (!) introduced a new context manager asyncio.timeout, which attaches a timeout to the current asyncio.Task. Any library or application that uses this feature will not be portable to other coroutine runners.<div><br></div><div>    with asyncio.timeout(1):</div><div>        result = await aiohttp.get('<a href="http://www.example.com">http://www.example.com</a>')<br><div><br></div><div>It's difficult to make this interface portable. We'd need to introduce a global thread-specific object that all of the coroutine runners could register the current task on, and define an interface that asyncio.timeout would call on that object to set the timeout. We could get rid of the global if the context manager used `async with` instead of `with`, since that would give us a way to communicate with the coroutine runner directly, but the net result is still that each runner needs to implement hooks for this feature (the hooks may or may not be generalizable to other features in the future).</div></div><div><br></div><div>If our goal is portability across coroutine runners, then asyncio.timeout() needs to go back to the drawing board. If the goal is to extend asyncio.Task to be the one true coroutine runner then we could leave it as-is.</div><div><br></div><div>For comparison, Tornado's equivalent to asyncio.timeout is tornado.gen.with_timeout(), and it has no special interactions with the coroutine runner:</div><div><br></div><div>    result = await with_timeout(timedelta(seconds=1),</div><div>                     convert_yielded(aiohttp.get("<a href="http://www.example.com">http://www.example.com</a>")))</div><div><br></div><div>(The convert_yielded call won't be needed in the next release of Tornado. The use of timedelta is because Tornado prefers absolute deadlines instead of relative timeouts, so that's how plain numbers are interpreted). </div><div><br></div><div>-Ben</div></div>