Skip to content

Parsing shouldn't end when the stream has no bytes available#46

Open
MihaiDamian wants to merge 2 commits intodavedelong:masterfrom
MihaiDamian:master
Open

Parsing shouldn't end when the stream has no bytes available#46
MihaiDamian wants to merge 2 commits intodavedelong:masterfrom
MihaiDamian:master

Conversation

@MihaiDamian
Copy link

The parser currently stops if the input stream has no available bytes to read. This seems incorrect as parsing should normally continue until the stream is closed, at an end or when an error has occurred. If hasBytesAvailable returns no it doesn't imply any of these cases, it could just be that the input stream is not yet ready to hand out data.

I encountered this limitation while trying to set up a producer-consumer relation between a network operation that downloaded a CSV and CHCSVParser. Because of network delays the parser can often read from the stream faster than the network operation can write.

The solution in this pull request is to wait in _loadMoreIfNecessary until further data is available, the stream ends or parsing is canceled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants