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 socketpair
Recipients gvanrossum, socketpair, vstinner, yselivanov
Date 2015-06-29.17:25:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1435598751.58.0.199860778997.issue24532@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-06-29 17:25:51socketpairsetrecipients: + socketpair, gvanrossum, vstinner, yselivanov
2015-06-29 17:25:51socketpairsetmessageid: <1435598751.58.0.199860778997.issue24532@psf.upfronthosting.co.za>
2015-06-29 17:25:51socketpairlinkissue24532 messages
2015-06-29 17:25:51socketpaircreate