Python: чтение длинных строк с помощью asyncio.StreamReader.readline()Python

Программы на Python
Anonymous
Python: чтение длинных строк с помощью asyncio.StreamReader.readline()

Сообщение Anonymous »


The asyncio version of readline() (1) allows reading a single line from a stream asynchronously. However, if it encounters a line that is longer than a limit, it will raise an exception (2). It is unclear how to resume reading after such an exception is raised.

I would like a function similar to readline(), that simply discards parts of lines that exceed the limit, and continues reading until the stream ends. Does such a method exist? If not, how to write one?

1: https://docs.python.org/3/library/async ... reamreader

2: https://github.com/python/cpython/blob/ ... ms.py#L549


Источник: https://stackoverflow.com/questions/780 ... r-readline

Вернуться в «Python»