Author yselivanov
Recipients gvanrossum, scoder, vstinner, yselivanov
Date 2015-06-04.15:42:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1433432578.55.0.498116142035.issue24383@psf.upfronthosting.co.za>
In-reply-to
Content
> Maybe it's possible to give an interpretation to awaiting on a threaded
> Future? __await__ could return a new asyncio Future, and add a completion
> callback to the original Future that makes the asyncio Future ready and
> transfers the result/exception. This would have to use
> loop.call_soon_threadsafe() to transfer control from the exector thread to
> the thread where the loop is running.

It didn't occur to me that we can implement __await__ on concurrent.Future to integrate it *with* asyncio.  I guess it makes sense (although we don't have this kind of integration in 3.4 with 'yield from')

> The only thing I don't know is whether it's possible for __await__ to
> return a Future.

It is -- we just have to return "iter(asyncio.Future())"

Please see the attached patch -- it needs some more tuning, but it demonstrates that the integration is possible.
History
Date User Action Args
2015-06-04 15:42:58yselivanovsetrecipients: + yselivanov, gvanrossum, scoder, vstinner
2015-06-04 15:42:58yselivanovsetmessageid: <1433432578.55.0.498116142035.issue24383@psf.upfronthosting.co.za>
2015-06-04 15:42:58yselivanovlinkissue24383 messages
2015-06-04 15:42:58yselivanovcreate