Martin Panter added the comment: If your event loop supports it, maybe you could use add_reader() etc as a workaround (roughly based off a different function of my own; this version completely untested):
async def sock_recvfrom(nonblocking_sock, *pos, loop, **kw): while True: try: return nonblocking_sock.recvfrom(*pos, **kw) except BlockingIOError: future = Future(loop=loop) loop.add_reader(nonblocking_sock.fileno(), future.set_result, None) try: await future finally: loop.remove_reader(nonblocking_sock.fileno()) I’m not very experienced with asyncio, but I imagine having general-purpose loop.wait_readable(file_descriptor) etc methods would make writing these kind of functions easier. ---------- nosy: +martin.panter _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26395> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com