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.

Author Paulo Costa
Recipients Paulo Costa, gvanrossum, vstinner, yselivanov
Date 2016-02-02.22:20:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I want to read from file descriptors from async coroutines.

I currently use `loop.add_reader(fd, callback)` and `loop.remove_reader(fd)`

It works, but IMO using callbacks feels completely alien in the middle of a coroutine.

I suggest adding new APIs to handle this. e.g.:
-, mode)
-, num)
- asyncio.write(fd, str)

(It would be nice to support all kinds of IO operations, but these are certainly the most important)

Using the current APIs, the async implementation of read() looks like this:

    async def async_read(fd. n):
        loop = asyncio.get_event_loop()
        future = asyncio.Future()

        def ready():
            future.set_result(, n))

        loop.add_reader(fd, ready)
        return future
Date User Action Args
2016-02-02 22:20:19Paulo Costasetrecipients: + Paulo Costa, gvanrossum, vstinner, yselivanov
2016-02-02 22:20:19Paulo Costasetmessageid: <>
2016-02-02 22:20:19Paulo Costalinkissue26270 messages
2016-02-02 22:20:19Paulo Costacreate