← index #6105PR #5953
Off-topic · high · value 0.376
QUERY · ISSUE

uasyncio V3 stream readline: is this correct?

openby peterhinchopened 2020-06-02updated 2020-06-04
extmod

The readline method returns if the final character is a newline. However it is possible that self.s.readline() might return more than one line. Should Stream.readline find the first newline and return a partial result? CPython docs:

Read one line, where “line” is a sequence of bytes ending with \n.

In the existing design the onus is on the device s to return a maximum of one line. Is this correct?

CANDIDATE · PULL REQUEST

uasyncio/stream: write immediately

closedby tveopened 2020-04-21updated 2022-06-24
extmod

I'm trying to eliminate buffer copies when using asyncio. These are particularly painful WRT memory fragmentation when using 1400 byte buffers to nicely fill packets... One reallocation & copy site is the uasyncio write method and I'm trying to find some way to use it where I can eliminate that copy. This PR is the best I've come up so far that doesn't diverge from CPython. In fact, it more closely implements the CPython doc semantics: "The method attempts to write the data to the underlying socket immediately. If that fails, the data is queued in an internal write buffer until it can be sent."

If this enhancement is acceptable I'd create some unit tests. I'm happy to hear about alternatives.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied