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 awalgarg
Recipients asvetlov, awalgarg, yselivanov
Date 2021-03-16.23:51:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615938675.3.0.818734595532.issue43524@roundup.psfhosted.org>
In-reply-to
Content
I propose the addition of the following methods to asyncio.StreamReader:

> coroutine peek(n=-1)
> Same as read, but does not remove the returned data from the internal buffer.
> 
> coroutine peekexactly(n)
> Same as readexactly, but does not remove the returned data from the internal buffer.

My use case is to multiplex a few protocols over a single TCP socket, for which I need to non-destructively read a few bytes from the socket to decide which parser to hand the stream over to.

Thoughts?
History
Date User Action Args
2021-03-16 23:51:15awalgargsetrecipients: + awalgarg, asvetlov, yselivanov
2021-03-16 23:51:15awalgargsetmessageid: <1615938675.3.0.818734595532.issue43524@roundup.psfhosted.org>
2021-03-16 23:51:15awalgarglinkissue43524 messages
2021-03-16 23:51:15awalgargcreate