New submission from Марк Коренберг: Suppose that program:
==================================== import asyncio import socket def receiver(loop): (a, b) = socket.socketpair() loop.call_later(1, lambda: print('Should be called inside the loop')) end = loop.time() + 3 print('Starting busy receiver') while loop.time() < end: a.send(b'test') yield from loop.sock_recv(b, 65536) # yield from asyncio.sleep(0) # <===================== print('Busy receiver complete') # just not to stop ioloop immediatelly yield from asyncio.sleep(0.5) def main(): loop = asyncio.get_event_loop() loop.run_until_complete(receiver(loop)) loop.close() if __name__ == '__main__': main() ==================================== Without asyncio.sleep(0) it will not fire time-delayed calls! If I add asyncio.sleep(0), everything work right. As I think, It is because recv() syscall is always succeeded, and we never return to ioloop (to epoll() I mean). In other words, it is classical `reader starvation` as mentioned in "man epoll". It is not documented, that this function may block event loop, in spite of it returns coroutine! I thought that this function will setup EPOLLIN event for socket's FD + call recv() after that. I spent many time to debug program. ---------- components: asyncio messages: 245952 nosy: gvanrossum, haypo, mmarkk, yselivanov priority: normal severity: normal status: open title: asyncio.sock_recv() blocks normal ioloop actions. type: behavior versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24532> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com