New submission from Awal Garg <awalg...@gmail.com>:

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?

----------
components: asyncio
messages: 388895
nosy: asvetlov, awalgarg, yselivanov
priority: normal
severity: normal
status: open
title: Addition of peek and peekexactly methods to asyncio.StreamReader
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43524>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to