Skip to content

Commit d2825af

Browse files
fix(examples/echo/echo.py): Add max message length to stream.read (#671)
Signed-off-by: varun-r-mallya <[email protected]>
1 parent 0f483dd commit d2825af

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

examples/echo/echo.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
)
2121

2222
PROTOCOL_ID = TProtocol("/echo/1.0.0")
23+
MAX_READ_LEN = 2**32 - 1
2324

2425

2526
async def _echo_stream_handler(stream: INetStream) -> None:
2627
# Wait until EOF
27-
msg = await stream.read()
28+
msg = await stream.read(MAX_READ_LEN)
2829
await stream.write(msg)
2930
await stream.close()
3031

@@ -72,10 +73,8 @@ async def run(port: int, destination: str, seed: int | None = None) -> None:
7273
msg = b"hi, there!\n"
7374

7475
await stream.write(msg)
75-
# TODO: check why the stream is closed after the first write ???
76-
# Notify the other side about EOF
77-
await stream.close()
7876
response = await stream.read()
77+
await stream.close()
7978

8079
print(f"Sent: {msg.decode('utf-8')}")
8180
print(f"Got: {response.decode('utf-8')}")

0 commit comments

Comments
 (0)