Message306397
While asyncio.StreamReader.readuntil is an improvement on only having readline, it is still quite limited e.g. you cannot have multiple possible terminators. The real problem is that it's not possible to roll your own without accessing _underscore fields (other than by reading one byte at a time, which I'm guessing would be bad for performance). I'm not sure exactly what a public API to assist would look like, but I think the following would be a good start:
1. A get_buffer method, that returns (self._buffer, self._eof); the caller must treat the buffer as readonly.
2. A wait_for_data method to wait for the return value of get_buffer to change (basically like current _wait_for_data)
3. Access to the _limit attribute.
With that available, I think readuntil or more complex variants of it could be implemented externally using only the public interface (consumption of data from the buffer would be via readexactly rather than by messing with the buffer array directly). |
|
Date |
User |
Action |
Args |
2017-11-16 19:09:48 | Bruce Merry | set | recipients:
+ Bruce Merry, yselivanov |
2017-11-16 19:09:48 | Bruce Merry | set | messageid: <1510859388.33.0.213398074469.issue32052@psf.upfronthosting.co.za> |
2017-11-16 19:09:48 | Bruce Merry | link | issue32052 messages |
2017-11-16 19:09:48 | Bruce Merry | create | |
|