New submission from Paulo Costa: 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.: - asyncio.select(fd, mode) - asyncio.read(fd, 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(os.read(fd, n)) loop.remove_reader(fd) loop.add_reader(fd, ready) return future ---------- components: asyncio messages: 259438 nosy: Paulo Costa, gvanrossum, haypo, yselivanov priority: normal severity: normal status: open title: Support for read()/write()/select() on asyncio type: enhancement _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26270> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com