You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the existing issues and didn't find my feature already requested there
Feature description
Sometimes applications or protocol implementations would benefit from the ability to see if there's data ready for reading from the stream, but without actually removing said data from the buffer. For socket streams, this could be implemented using recv() with the MSG_PEEK flag. This should work on all platforms. For TLS streams, this is also doable but a tad more complex. One consideration would be that the stream might not return the same result when a destructive read is done after a non-destructive read with a yield point in between, but I think this could just be documented (and can be avoided by not sharing the stream among tasks in the first place).
Use case
This was mainly inspired by redis-py wanting to defensively check if the stream has any more data to be read. That said, I've come across other cases which I can't quite remember, where the knowledge of pending incoming data would help optimize the operation of a protocol implementation.
The text was updated successfully, but these errors were encountered:
Things to check first
Feature description
Sometimes applications or protocol implementations would benefit from the ability to see if there's data ready for reading from the stream, but without actually removing said data from the buffer. For socket streams, this could be implemented using
recv()
with theMSG_PEEK
flag. This should work on all platforms. For TLS streams, this is also doable but a tad more complex. One consideration would be that the stream might not return the same result when a destructive read is done after a non-destructive read with a yield point in between, but I think this could just be documented (and can be avoided by not sharing the stream among tasks in the first place).Use case
This was mainly inspired by redis-py wanting to defensively check if the stream has any more data to be read. That said, I've come across other cases which I can't quite remember, where the knowledge of pending incoming data would help optimize the operation of a protocol implementation.
The text was updated successfully, but these errors were encountered: