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 aymeric.augustin
Recipients RemiCardona, aymeric.augustin, metathink, vstinner, yselivanov
Date 2017-03-29.07:41:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490773275.57.0.645485268998.issue29930@psf.upfronthosting.co.za>
In-reply-to
Content
drain() returns when the write buffer reaches the low water mark, not when it's empty, so you don't have a guarantee that your bytes were written to the socket.

https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/asyncio/protocols.py#L36-L40

The low water mark defaults to 64kB and the high water mark to 256kB.

https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/asyncio/transports.py#L290

With websockets, the recommended way to ensure your message was received is:

yield from ws.send(...)
yield from ws.ping()

Given that TCP guarantees ordering, the ping response can only be received after the previous message was fully sent and received.

Of course the ping can fail even though the message was received, that's the classical at-most-once vs. at-least-once question.

The technique you suggest requires setting the low and high water marks to 0. I'm not sure this is the best way to achieve your goals, since you still don't control the OS buffers.
History
Date User Action Args
2017-03-29 07:41:15aymeric.augustinsetrecipients: + aymeric.augustin, vstinner, yselivanov, RemiCardona, metathink
2017-03-29 07:41:15aymeric.augustinsetmessageid: <1490773275.57.0.645485268998.issue29930@psf.upfronthosting.co.za>
2017-03-29 07:41:15aymeric.augustinlinkissue29930 messages
2017-03-29 07:41:14aymeric.augustincreate